• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang store.NewStore函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry/hm9000/store.NewStore函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStore函数的具体用法?Golang NewStore怎么用?Golang NewStore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewStore函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: makeHandlerAndStore

func makeHandlerAndStore(conf HandlerConf) (http.Handler, store.Store, error) {
	config, _ := config.DefaultConfig()

	store := store.NewStore(config, conf.StoreAdapter, fakelogger.NewFakeLogger())

	handler, err := handlers.New(conf.Logger, store, conf.TimeProvider)
	return handler, store, err
}
开发者ID:cgrotz,项目名称:hm9000,代码行数:8,代码来源:bulk_app_state_test.go


示例2: connectToStore

func connectToStore(l logger.Logger, conf *config.Config) (store.Store, metricsaccountant.UsageTracker) {
	if conf.StoreType == "etcd" || conf.StoreType == "ZooKeeper" {
		adapter, workerPool := connectToStoreAdapter(l, conf)
		return store.NewStore(conf, adapter, l), workerPool
	} 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)
	}

	return nil, nil
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:11,代码来源:common.go


示例3: PrepForNextTest

func (coordinator *MCATCoordinator) PrepForNextTest() (*CLIRunner, *Simulator, *startstoplistener.StartStopListener) {
	coordinator.StoreRunner.Reset()
	coordinator.startStopListener.Reset()
	coordinator.StateServer.Reset()

	if coordinator.currentCLIRunner != nil {
		coordinator.currentCLIRunner.Cleanup()
	}
	coordinator.currentCLIRunner = NewCLIRunner(coordinator.StoreRunner.NodeURLS(), coordinator.DesiredStateServerBaseUrl, coordinator.NatsPort, coordinator.MetricsServerPort, coordinator.Verbose)
	store := storepackage.NewStore(coordinator.Conf, coordinator.StoreAdapter, fakelogger.NewFakeLogger())
	simulator := NewSimulator(coordinator.Conf, coordinator.StoreRunner, store, coordinator.StateServer, coordinator.currentCLIRunner, coordinator.MessageBus)

	return coordinator.currentCLIRunner, simulator, coordinator.startStopListener
}
开发者ID:philwhln,项目名称:hm9000,代码行数:14,代码来源:mcat_coordinator_test.go


示例4: main

func main() {
	cmdsToStop = []*exec.Cmd{}

	registerSignalHandler()
	nats = natsrunner.NewNATSRunner(4222)
	nats.Start()

	fakeCC := desiredstateserver.NewDesiredStateServer()
	go fakeCC.SpinUp(6001)

	// etcd = storerunner.NewETCDClusterRunner(4001, 1)
	// etcd.Start()
	conf, _ := config.FromFile("./config.json")
	adapter := storeadapter.NewETCDStoreAdapter(conf.StoreURLs, workerpool.NewWorkerPool(30))
	adapter.Connect()
	store = storepackage.NewStore(conf, adapter, fakelogger.NewFakeLogger())

	r := rand.New(rand.NewSource(time.Now().Unix()))
	num, err := strconv.Atoi(os.Args[1])
	if err != nil {
		panic(err)
	}

	sim := simulator.New(num, 10, r, nats.MessageBus, fakeCC)
	//start all the HM components (make them pipe to stdout)
	start("listen", false)
	start("fetch_desired", true)
	start("analyze", true)
	start("send", true)
	start("serve_metrics", false)
	start("serve_api", false)
	time.Sleep(time.Second)
	go Tick(sim)
	go Fetch()
	select {}
}
开发者ID:pivotal-cf-experimental,项目名称:hmperformance,代码行数:36,代码来源:benchmarks.go


示例5: connectToStore

func connectToStore(l logger.Logger, conf *config.Config) (store.Store, metricsaccountant.UsageTracker) {
	adapter, workerPool := connectToStoreAdapter(l, conf)
	return store.NewStore(conf, adapter, l), workerPool
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:4,代码来源:common.go


示例6:

	"github.com/cloudfoundry/storeadapter/fakestoreadapter"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"time"
)

var _ = Describe("Metrics Accountant", func() {
	var store storepackage.Store
	var accountant MetricsAccountant
	var fakeStoreAdapter *fakestoreadapter.FakeStoreAdapter

	conf, _ := config.DefaultConfig()

	BeforeEach(func() {
		fakeStoreAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, fakeStoreAdapter, fakelogger.NewFakeLogger())
		accountant = New(store)
	})

	Describe("Getting Metrics", func() {
		Context("when the store is empty", func() {
			It("should return a map of 0s", func() {
				metrics, err := accountant.GetMetrics()
				Ω(err).ShouldNot(HaveOccurred())
				Ω(metrics).Should(Equal(map[string]float64{
					"StartCrashed":                            0,
					"StartMissing":                            0,
					"StartEvacuating":                         0,
					"StopExtra":                               0,
					"StopDuplicate":                           0,
					"StopEvacuationComplete":                  0,
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:31,代码来源:metricsaccountant_test.go


示例7: connectToStoreAndTrack

func connectToStoreAndTrack(l logger.Logger, conf *config.Config) (store.Store, metricsaccountant.UsageTracker) {
	tracker := newUsageTracker(conf.StoreMaxConcurrentRequests)
	adapter := connectToStoreAdapter(l, conf)
	return store.NewStore(conf, adapter, l), tracker
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:5,代码来源:common.go


示例8: connectToStore

func connectToStore(l logger.Logger, conf *config.Config) store.Store {
	adapter := connectToStoreAdapter(l, conf)
	return store.NewStore(conf, adapter, l)
}
开发者ID:nagyistge,项目名称:hm9000,代码行数:4,代码来源:common.go


示例9:

		resultChan chan desiredstatefetcher.DesiredStateFetcherResult
	)

	BeforeEach(func() {
		resultChan = make(chan desiredstatefetcher.DesiredStateFetcherResult, 1)
		a1 = app.NewApp()
		a2 = app.NewApp()
		a3 = app.NewApp()

		stateServer.SetDesiredState([]models.DesiredAppState{
			a1.DesiredState(0),
			a2.DesiredState(0),
			a3.DesiredState(0),
		})

		fetcher = desiredstatefetcher.New(conf, natsRunner.MessageBus, store.NewStore(conf, storeAdapter), httpclient.NewHttpClient(), &timeprovider.RealTimeProvider{})
		fetcher.Fetch(resultChan)
	})

	It("requests for the first set of data from the CC and stores the response", func() {
		var node storeadapter.StoreNode
		var err error
		Eventually(func() error {
			node, err = storeAdapter.Get("/desired/" + a1.AppGuid + "-" + a1.AppVersion)
			return err
		}, 1, 0.1).ShouldNot(HaveOccured())

		Ω(node.TTL).Should(BeNumerically("<=", 10*60))
		Ω(node.TTL).Should(BeNumerically(">=", 10*60-1))

		Ω(node.Value).Should(Equal(a1.DesiredState(0).ToJson()))
开发者ID:Zhann,项目名称:hm9000,代码行数:31,代码来源:desired_state_fetcher_integration_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang store.Store类代码示例发布时间:2022-05-23
下一篇:
Golang models.PendingStopMessage类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap