當前位置: 首頁>>代碼示例>>Golang>>正文


Golang etcdstoreadapter.NewETCDStoreAdapter函數代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/storeadapter/etcdstoreadapter.NewETCDStoreAdapter函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewETCDStoreAdapter函數的具體用法?Golang NewETCDStoreAdapter怎麽用?Golang NewETCDStoreAdapter使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewETCDStoreAdapter函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	flag.Parse()

	//make the out dir
	logger.Component = "SIMULATOR"
	if outDir == "" {
		logger.Fatal("out.dir.unspecified")
	}
	err := os.MkdirAll(outDir, 0777)
	if err != nil {
		logger.Fatal("out.dir.creation.failed", err)
	}

	//set up logging
	outputFile, err := os.Create(filepath.Join(outDir, "simulator.log"))
	if err != nil {
		logger.Fatal("failed.to.create.simulator.log", err)
	}
	logger.Writer = io.MultiWriter(os.Stdout, outputFile)
	cleanup.Register(func() {
		outputFile.Sync()
	})

	//compile the executor
	logger.Info("compiling.executor")
	output, err := exec.Command("go", "install", "github.com/cloudfoundry-incubator/simulator/game_executor").CombinedOutput()
	if err != nil {
		logger.Fatal("failed.to.compile.executor", string(output))
	}

	//write info to the output dir
	writeInfo()

	//start etcd
	logger.Info("starting.etcd", etcdNodes)
	etcd = etcdstorerunner.NewETCDClusterRunner(4001, etcdNodes)
	etcd.Start()

	//set up the bbs
	pool := workerpool.NewWorkerPool(50)
	etcdAdapter = etcdstoreadapter.NewETCDStoreAdapter(etcd.NodeURLS(), pool)
	etcdAdapter.Connect()
	bbs = Bbs.New(etcdAdapter, timeprovider.NewTimeProvider())

	//monitor etcd
	monitorETCD()

	//start executors
	startExecutors()

	cleanup.Register(func() {
		logger.Info("stopping.etcd", etcdNodes)
		etcd.Stop()
	})

	//run the simulator
	runSimulation()

	cleanup.Exit(0)
}
開發者ID:vito,項目名稱:diego-sim,代碼行數:60,代碼來源:simulator.go

示例2: main

func main() {
	flag.Parse()

	runtime.GOMAXPROCS(runtime.NumCPU())

	table := map[string]Route{}

	transport := &http.Transport{
		ResponseHeaderTimeout: 10 * time.Second,
	}

	handler := &Handler{
		table:     table,
		transport: transport,
	}

	etcdAdapter := etcdstoreadapter.NewETCDStoreAdapter(
		strings.Split(*etcdCluster, ","),
		workerpool.NewWorkerPool(10),
	)
	err := etcdAdapter.Connect()
	if err != nil {
		log.Fatalln("can't connect to etcd:", err)
	}

	go handler.syncTable(etcdAdapter, *syncInterval)

	http.Handle("/", handler)

	http.ListenAndServe(*listenAddr, nil)
}
開發者ID:vito,項目名稱:fake-diego-release,代碼行數:31,代碼來源:main.go

示例3: NewETCD

func NewETCD(nodeURLs []string) etcd {
	workpool := workpool.NewWorkPool(1)
	storeAdapter := etcdstoreadapter.NewETCDStoreAdapter(nodeURLs, workpool)
	return etcd{
		storeAdapter: storeAdapter,
	}
}
開發者ID:trainchou,項目名稱:gorouter,代碼行數:7,代碼來源:db.go

示例4: Adapter

func (etcd *ETCDClusterRunner) Adapter() storeadapter.StoreAdapter {
	pool, err := workpool.NewWorkPool(10)
	Expect(err).NotTo(HaveOccurred())
	adapter := etcdstoreadapter.NewETCDStoreAdapter(etcd.NodeURLS(), pool)
	adapter.Connect()
	return adapter
}
開發者ID:qinguoan,項目名稱:vulcan,代碼行數:7,代碼來源:etcd_cluster_runner.go

示例5: storeAdapterProvider

func storeAdapterProvider(urls []string, concurrentRequests int) storeadapter.StoreAdapter {
	workPool, err := workpool.NewWorkPool(concurrentRequests)
	if err != nil {
		panic(err)
	}

	return etcdstoreadapter.NewETCDStoreAdapter(urls, workPool)
}
開發者ID:jvshahid,項目名稱:loggregator,代碼行數:8,代碼來源:main.go

示例6: NewStoreAdapter

func NewStoreAdapter(urls []string, concurrentRequests int) storeadapter.StoreAdapter {
	workPool, err := workpool.NewWorkPool(concurrentRequests)
	if err != nil {
		panic(err)
	}
	etcdStoreAdapter := etcdstoreadapter.NewETCDStoreAdapter(urls, workPool)
	etcdStoreAdapter.Connect()
	return etcdStoreAdapter
}
開發者ID:JimmyMa,項目名稱:loggregator,代碼行數:9,代碼來源:main.go

示例7: StartETCD

func (coordinator *MCATCoordinator) StartETCD() {
	etcdPort := 5000 + (coordinator.ParallelNode-1)*10
	coordinator.StoreRunner = etcdstorerunner.NewETCDClusterRunner(etcdPort, 1)
	coordinator.StoreRunner.Start()

	coordinator.StoreAdapter = etcdstoreadapter.NewETCDStoreAdapter(coordinator.StoreRunner.NodeURLS(), workerpool.NewWorkerPool(coordinator.Conf.StoreMaxConcurrentRequests))
	err := coordinator.StoreAdapter.Connect()
	Ω(err).ShouldNot(HaveOccurred())
}
開發者ID:philwhln,項目名稱:hm9000,代碼行數:9,代碼來源:mcat_coordinator_test.go

示例8: NewETCD

func NewETCD(nodeURLs []string, maxWorkers uint) (*etcd, error) {
	workpool, err := workpool.NewWorkPool(int(maxWorkers))
	if err != nil {
		return nil, err
	}

	storeAdapter := etcdstoreadapter.NewETCDStoreAdapter(nodeURLs, workpool)
	return &etcd{
		storeAdapter: storeAdapter,
	}, nil
}
開發者ID:qinguoan,項目名稱:vulcan,代碼行數:11,代碼來源:db.go

示例9: 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

示例10: main

func main() {
	flag.Parse()

	datadogApiKey := os.Getenv("DATADOG_API_KEY")
	datadogAppKey := os.Getenv("DATADOG_APP_KEY")

	var datadogClient *datadog.Client

	if datadogApiKey != "" {
		datadogClient = datadog.NewClient(datadogApiKey, datadogAppKey)
	}

	store := etcdstoreadapter.NewETCDStoreAdapter(
		strings.Split(*etcdMachines, ","),
		workerpool.NewWorkerPool(50),
	)

	err := store.Connect()
	if err != nil {
		log.Fatalln("failed to connect to store:", err)
	}

	if *emitStates {
		// logging mode
		etcd_logger.EmitRunOnceStates(datadogClient, store, strings.Split(*etcdMachines, ","))
	} else {
		// stampede mode

		runOnce := &models.RunOnce{
			Actions: []models.ExecutorAction{
				{
					models.RunAction{
						Script:  *script,
						Timeout: *timeout,
					},
				},
			},
			Stack:    *stack,
			MemoryMB: *memoryMB,
			DiskMB:   *diskMB,
		}

		if *logGuid != "" {
			runOnce.Log = models.LogConfig{
				Guid:       *logGuid,
				SourceName: *logSourceName,
			}
		}
		stampede.RunonceStampede(bbs.New(store, timeprovider.NewTimeProvider()), datadogClient, runOnce, *runOnceCount)
	}

}
開發者ID:pivotal-cf-experimental,項目名稱:executor-tester,代碼行數:52,代碼來源:main.go

示例11: RetryableAdapter

func (etcd *ETCDClusterRunner) RetryableAdapter(workPoolSize int) storeadapter.StoreAdapter {
	pool, err := workpool.NewWorkPool(workPoolSize)
	Expect(err).NotTo(HaveOccurred())

	adapter := storeadapter.NewRetryable(
		etcdstoreadapter.NewETCDStoreAdapter(etcd.NodeURLS(), pool),
		clock.NewClock(),
		storeadapter.ExponentialRetryPolicy{},
	)

	adapter.Connect()

	return adapter
}
開發者ID:qinguoan,項目名稱:vulcan,代碼行數:14,代碼來源:etcd_cluster_runner.go

示例12: 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

示例13: 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

示例14: main

func main() {
	flag.Parse()
	cleanup.Register(func() {
		logger.Info("executor.shuttingdown")
		close(stop)
		tasks.Wait()
		logger.Info("executor.shutdown")
	})
	logger.Component = fmt.Sprintf("EXECUTOR %s", *executorID)

	lock = &sync.Mutex{}
	currentMemory = *maxMemory

	etcdAdapter := etcdstoreadapter.NewETCDStoreAdapter(
		strings.Split(*etcdCluster, ","),
		workerpool.NewWorkerPool(10),
	)
	err := etcdAdapter.Connect()
	if err != nil {
		logger.Fatal("etcd.connect.fatal", err)
	}

	tasks = &sync.WaitGroup{}
	stop = make(chan bool)

	bbs := Bbs.New(etcdAdapter, timeprovider.NewTimeProvider())

	ready := make(chan bool, 1)

	err = maintainPresence(bbs, ready)
	if err != nil {
		logger.Fatal("executor.initializing-presence.failed", err)
	}

	go handleRunOnces(bbs)
	go convergeRunOnces(bbs)

	<-ready

	logger.Info("executor.up")

	select {}
}
開發者ID:vito,項目名稱:diego-sim,代碼行數:43,代碼來源:game_executor.go

示例15: Adapter

func (etcd *ETCDClusterRunner) Adapter() storeadapter.StoreAdapter {
	pool := workpool.NewWorkPool(10)
	adapter := etcdstoreadapter.NewETCDStoreAdapter(etcd.NodeURLS(), pool)
	adapter.Connect()
	return adapter
}
開發者ID:trainchou,項目名稱:gorouter,代碼行數:6,代碼來源:etcd_cluster_runner.go


注:本文中的github.com/cloudfoundry/storeadapter/etcdstoreadapter.NewETCDStoreAdapter函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。