本文整理汇总了Golang中github.com/cloudfoundry/hm9000/storeadapter.StoreAdapter.Connect方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.Connect方法的具体用法?Golang StoreAdapter.Connect怎么用?Golang StoreAdapter.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/hm9000/storeadapter.StoreAdapter
的用法示例。
在下文中一共展示了StoreAdapter.Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
for _, storeType := range storeTypes {
storeType := storeType
for _, nodes := range nodeCounts {
nodes := nodes
for _, concurrency := range concurrencies {
concurrency := concurrency
Context(fmt.Sprintf("With %d %s nodes (%d concurrent requests at a time)", nodes, storeType, concurrency), func() {
var storeAdapter storeadapter.StoreAdapter
BeforeEach(func() {
if storeType == "ETCD" {
storeRunner = storerunner.NewETCDClusterRunner(5001, nodes)
storeRunner.Start()
storeAdapter = storeadapter.NewETCDStoreAdapter(storeRunner.NodeURLS(), workerpool.NewWorkerPool(concurrency))
err := storeAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
} else if storeType == "Zookeeper" {
storeRunner = storerunner.NewZookeeperClusterRunner(2181, nodes)
storeRunner.Start()
storeAdapter = storeadapter.NewZookeeperStoreAdapter(storeRunner.NodeURLS(), workerpool.NewWorkerPool(concurrency), &timeprovider.RealTimeProvider{}, time.Second)
err := storeAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
}
})
AfterEach(func() {
storeAdapter.Disconnect()
storeRunner.Stop()
storeRunner = nil
示例2:
var _ = Describe("Desired State", func() {
var (
store Store
etcdAdapter storeadapter.StoreAdapter
conf config.Config
app1 app.App
app2 app.App
app3 app.App
)
BeforeEach(func() {
var err error
conf, err = config.DefaultConfig()
Ω(err).ShouldNot(HaveOccured())
etcdAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err = etcdAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
app1 = app.NewApp()
app2 = app.NewApp()
app3 = app.NewApp()
store = NewStore(conf, etcdAdapter)
})
AfterEach(func() {
etcdAdapter.Disconnect()
})
Describe("Saving desired state ", func() {
BeforeEach(func() {
示例3:
var _ = Describe("Analyzer", func() {
var (
analyzer *Analyzer
etcdStoreAdapter storeadapter.StoreAdapter
conf config.Config
a1 app.App
a2 app.App
)
BeforeEach(func() {
var err error
conf, err = config.DefaultConfig()
Ω(err).ShouldNot(HaveOccured())
etcdStoreAdapter = storeadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), conf.StoreMaxConcurrentRequests)
err = etcdStoreAdapter.Connect()
Ω(err).ShouldNot(HaveOccured())
a1 = app.NewApp()
a2 = app.NewApp()
analyzer = New(etcdStoreAdapter)
})
insertDesiredIntoStore := func(desired models.DesiredAppState) {
key := "/desired/" + desired.StoreKey()
value := desired.ToJson()
node := storeadapter.StoreNode{
Key: key,
Value: value,