本文整理汇总了Golang中github.com/cloudfoundry/storeadapter.StoreAdapter.Connect方法的典型用法代码示例。如果您正苦于以下问题:Golang StoreAdapter.Connect方法的具体用法?Golang StoreAdapter.Connect怎么用?Golang StoreAdapter.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/storeadapter.StoreAdapter
的用法示例。
在下文中一共展示了StoreAdapter.Connect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: connectToStoreAdapter
func connectToStoreAdapter(l logger.Logger, conf *config.Config) storeadapter.StoreAdapter {
var adapter storeadapter.StoreAdapter
workPool, err := workpool.NewWorkPool(conf.StoreMaxConcurrentRequests)
if err != nil {
l.Error("Failed to create workpool", err)
os.Exit(1)
}
options := &etcdstoreadapter.ETCDOptions{
ClusterUrls: conf.StoreURLs,
}
adapter, err = etcdstoreadapter.New(options, workPool)
if err != nil {
l.Error("Failed to create the store adapter", err)
os.Exit(1)
}
err = adapter.Connect()
if err != nil {
l.Error("Failed to connect to the store", err)
os.Exit(1)
}
return adapter
}
示例2: connectToStoreAdapter
func connectToStoreAdapter(l logger.Logger, conf *config.Config) (storeadapter.StoreAdapter, metricsaccountant.UsageTracker) {
var adapter storeadapter.StoreAdapter
workerPool := workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests)
adapter = etcdstoreadapter.NewETCDStoreAdapter(conf.StoreURLs, workerPool)
err := adapter.Connect()
if err != nil {
l.Error("Failed to connect to the store", err)
os.Exit(1)
}
return adapter, workerPool
}
示例3: connectToStoreAdapter
func connectToStoreAdapter(l logger.Logger, conf *config.Config, usage *usageTracker) storeadapter.StoreAdapter {
var adapter storeadapter.StoreAdapter
var around workpool.AroundWork = workpool.DefaultAround
if usage != nil {
around = usage
}
workPool := workpool.New(conf.StoreMaxConcurrentRequests, 0, around)
adapter = etcdstoreadapter.NewETCDStoreAdapter(conf.StoreURLs, workPool)
err := adapter.Connect()
if err != nil {
l.Error("Failed to connect to the store", err)
os.Exit(1)
}
return adapter
}
示例4: connectToStoreAdapter
func connectToStoreAdapter(l logger.Logger, conf *config.Config) (storeadapter.StoreAdapter, metricsaccountant.UsageTracker) {
var adapter storeadapter.StoreAdapter
workerPool := workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests)
if conf.StoreType == "etcd" {
adapter = etcdstoreadapter.NewETCDStoreAdapter(conf.StoreURLs, workerPool)
} else if conf.StoreType == "ZooKeeper" {
adapter = zookeeperstoreadapter.NewZookeeperStoreAdapter(conf.StoreURLs, workerPool, buildTimeProvider(l), time.Second)
} else {
l.Error(fmt.Sprintf("Unknown store type %s. Choose one of 'etcd' or 'ZooKeeper'", conf.StoreType), fmt.Errorf("Unkown store type"))
os.Exit(1)
}
err := adapter.Connect()
if err != nil {
l.Error("Failed to connect to the store", err)
os.Exit(1)
}
return adapter, workerPool
}
示例5: NewElector
func NewElector(instanceName string, adapter storeadapter.StoreAdapter, updateInterval time.Duration, logger *gosteno.Logger) *Elector {
for {
err := adapter.Connect()
if err == nil {
break
}
logger.Errorf("Elector: Unable to connect to store: '%s'", err.Error())
time.Sleep(updateInterval)
}
return &Elector{
instanceName: []byte(instanceName),
adapter: adapter,
updateInterval: updateInterval,
logger: logger,
}
}
示例6:
storeAdapter storeadapter.StoreAdapter
conf *config.Config
dea appfixture.DeaFixture
app1 appfixture.AppFixture
app2 appfixture.AppFixture
app3 appfixture.AppFixture
app4 appfixture.AppFixture
crashCount []models.CrashCount
)
conf, _ = config.DefaultConfig()
BeforeEach(func() {
storeAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcdRunner.NodeURLS(), workerpool.NewWorkerPool(conf.StoreMaxConcurrentRequests))
err := storeAdapter.Connect()
Ω(err).ShouldNot(HaveOccurred())
store = NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
dea = appfixture.NewDeaFixture()
app1 = dea.GetApp(0)
app2 = dea.GetApp(1)
app3 = dea.GetApp(2)
app4 = dea.GetApp(3)
actualState := []models.InstanceHeartbeat{
app1.InstanceAtIndex(0).Heartbeat(),
app1.InstanceAtIndex(1).Heartbeat(),
app1.InstanceAtIndex(2).Heartbeat(),
app2.InstanceAtIndex(0).Heartbeat(),
示例7:
BeforeEach(func() {
app1Service1 = appservice.AppService{AppId: APP1_ID, Url: "syslog://example.com:12345"}
app1Service2 = appservice.AppService{AppId: APP1_ID, Url: "syslog://example.com:12346"}
app2Service1 = appservice.AppService{AppId: APP2_ID, Url: "syslog://example.com:12345"}
workPool, err := workpool.NewWorkPool(10)
Expect(err).NotTo(HaveOccurred())
options := &etcdstoreadapter.ETCDOptions{
ClusterUrls: etcdRunner.NodeURLS(),
}
adapter, err = etcdstoreadapter.New(options, workPool)
Expect(err).NotTo(HaveOccurred())
err = adapter.Connect()
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() {