本文整理汇总了Golang中github.com/cloudfoundry/storeadapter.StoreAdapter.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.Disconnect方法的具体用法?Golang StoreAdapter.Disconnect怎么用?Golang StoreAdapter.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/storeadapter.StoreAdapter
的用法示例。
在下文中一共展示了StoreAdapter.Disconnect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
var err error
conf, err = config.DefaultConfig()
Ω(err).ShouldNot(HaveOccurred())
storeAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests))
err = storeAdapter.Connect()
Ω(err).ShouldNot(HaveOccurred())
message1 = models.NewPendingStopMessage(time.Unix(100, 0), 10, 4, "ABC", "123", "XYZ", models.PendingStopMessageReasonInvalid)
message2 = models.NewPendingStopMessage(time.Unix(100, 0), 10, 4, "DEF", "456", "ALPHA", models.PendingStopMessageReasonInvalid)
message3 = models.NewPendingStopMessage(time.Unix(100, 0), 10, 4, "GHI", "789", "BETA", models.PendingStopMessageReasonInvalid)
store = NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
})
AfterEach(func() {
storeAdapter.Disconnect()
})
Describe("Saving stop messages", func() {
BeforeEach(func() {
err := store.SavePendingStopMessages(
message1,
message2,
)
Ω(err).ShouldNot(HaveOccurred())
})
It("stores the passed in stop messages", func() {
node, err := storeAdapter.ListRecursively("/hm/v1/stop")
Ω(err).ShouldNot(HaveOccurred())
Ω(node.ChildNodes).Should(HaveLen(2))
示例2: startComponent
func startComponent(path string, shortName string, colorCode uint64, arg ...string) *gexec.Session {
var session *gexec.Session
var err error
startCommand := exec.Command(path, arg...)
session, err = gexec.Start(
startCommand,
gexec.NewPrefixedWriter(fmt.Sprintf("\x1b[32m[o]\x1b[%dm[%s]\x1b[0m ", colorCode, shortName), GinkgoWriter),
gexec.NewPrefixedWriter(fmt.Sprintf("\x1b[91m[e]\x1b[%dm[%s]\x1b[0m ", colorCode, shortName), GinkgoWriter))
Expect(err).ShouldNot(HaveOccurred())
return session
}
func waitOnURL(url string) {
Eventually(func() error {
_, err := http.Get(url)
return err
}, 3).ShouldNot(HaveOccurred())
}
var _ = AfterEach(func() {
metronSession.Kill().Wait()
dopplerSession.Kill().Wait()
tcSession.Kill().Wait()
})
var _ = AfterSuite(func() {
etcdAdapter.Disconnect()
etcdRunner.Stop()
gexec.CleanupBuildArtifacts()
})
示例3: TestDB
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestDB(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "DB Suite")
}
var etcdClient storeadapter.StoreAdapter
var etcdPort int
var etcdUrl string
var etcdRunner *etcdstorerunner.ETCDClusterRunner
var routingAPIBinPath string
var _ = BeforeEach(func() {
etcdPort = 4001 + GinkgoParallelNode()
etcdUrl = fmt.Sprintf("http://127.0.0.1:%d", etcdPort)
etcdRunner = etcdstorerunner.NewETCDClusterRunner(etcdPort, 1)
etcdRunner.Start()
etcdClient = etcdRunner.Adapter()
})
var _ = AfterEach(func() {
etcdClient.Disconnect()
etcdRunner.Stop()
})
示例4:
}
return appServices
}
BeforeEach(func() {
adapter = etcdRunner.Adapter()
listener, outAddChan, outRemoveChan = NewAppServiceStoreWatcher(adapter)
app1Service1 = domain.AppService{AppId: "app-1", Url: "syslog://example.com:12345"}
app1Service2 = domain.AppService{AppId: "app-1", Url: "syslog://example.com:12346"}
app2Service1 = domain.AppService{AppId: "app-2", Url: "syslog://example.com:12345"}
})
AfterEach(func() {
err := adapter.Disconnect()
Expect(err).NotTo(HaveOccurred())
})
Describe("Shutdown", func() {
BeforeEach(func() {
go listener.Run()
adapter.Disconnect()
})
PIt("should close the outgoing channels", func() {
Expect(outAddChan).To(BeClosed())
Expect(outRemoveChan).To(BeClosed())
})
})
示例5:
Expect(err).NotTo(HaveOccurred())
c := cache.NewAppServiceCache()
watcher, outAddChan, outRemoveChan = NewAppServiceStoreWatcher(adapter, c, loggertesthelper.Logger())
runWatcher = func() {
watcherRunComplete.Add(1)
go func() {
watcher.Run()
watcherRunComplete.Done()
}()
}
})
AfterEach(func() {
Expect(adapter.Disconnect()).To(Succeed())
watcherRunComplete.Wait()
})
Describe("Shutdown", func() {
It("should close the outgoing channels", func() {
runWatcher()
time.Sleep(500 * time.Millisecond)
adapter.Disconnect()
Eventually(outRemoveChan).Should(BeClosed())
Eventually(outAddChan).Should(BeClosed())
})
})