当前位置: 首页>>代码示例>>Golang>>正文


Golang StoreAdapter.Connect方法代码示例

本文整理汇总了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
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:25,代码来源:common.go

示例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
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:12,代码来源:common.go

示例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
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:16,代码来源:common.go

示例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
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:19,代码来源:common.go

示例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,
	}
}
开发者ID:lyuyun,项目名称:loggregator,代码行数:19,代码来源:elector.go

示例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(),
开发者ID:KeyOfSpectator,项目名称:hm9000,代码行数:31,代码来源:apps_test.go

示例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() {
开发者ID:pkdevbox,项目名称:loggregatorlib,代码行数:30,代码来源:app_service_store_watcher_test.go


注:本文中的github.com/cloudfoundry/storeadapter.StoreAdapter.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。