本文整理汇总了Golang中github.com/cloudfoundry/gunk/workpool.NewWorkPool函数的典型用法代码示例。如果您正苦于以下问题:Golang NewWorkPool函数的具体用法?Golang NewWorkPool怎么用?Golang NewWorkPool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewWorkPool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewETCD
func NewETCD(nodeURLs []string) etcd {
workpool := workpool.NewWorkPool(1)
storeAdapter := etcdstoreadapter.NewETCDStoreAdapter(nodeURLs, workpool)
return etcd{
storeAdapter: storeAdapter,
}
}
示例2: 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
}
示例3: NewGardenStore
func NewGardenStore(
gardenClient garden.Client,
containerOwnerName string,
containerMaxCPUShares uint64,
containerInodeLimit uint64,
healthyMonitoringInterval time.Duration,
unhealthyMonitoringInterval time.Duration,
transformer *transformer.Transformer,
clock clock.Clock,
eventEmitter EventEmitter,
healthCheckWorkPoolSize int,
) (*GardenStore, error) {
workPool, err := workpool.NewWorkPool(healthCheckWorkPoolSize)
if err != nil {
return nil, err
}
return &GardenStore{
gardenClient: gardenClient,
exchanger: NewExchanger(containerOwnerName, containerMaxCPUShares, containerInodeLimit),
containerOwnerName: containerOwnerName,
healthyMonitoringInterval: healthyMonitoringInterval,
unhealthyMonitoringInterval: unhealthyMonitoringInterval,
transformer: transformer,
clock: clock,
eventEmitter: eventEmitter,
runningProcesses: map[string]ifrit.Process{},
workPool: workPool,
}, nil
}
示例4: initializeReceptorBBS
func initializeReceptorBBS(etcdOptions *etcdstoreadapter.ETCDOptions, logger lager.Logger) Bbs.ReceptorBBS {
workPool, err := workpool.NewWorkPool(100)
if err != nil {
logger.Fatal("failed-to-construct-etcd-adapter-workpool", err, lager.Data{"num-workers": 100}) // should never happen
}
etcdAdapter, err := etcdstoreadapter.New(etcdOptions, workPool)
if err != nil {
logger.Fatal("failed-to-construct-etcd-tls-client", err)
}
client, err := consuladapter.NewClient(*consulCluster)
if err != nil {
logger.Fatal("new-client-failed", err)
}
sessionMgr := consuladapter.NewSessionManager(client)
consulSession, err := consuladapter.NewSession("receptor", *lockTTL, client, sessionMgr)
if err != nil {
logger.Fatal("consul-session-failed", err)
}
return Bbs.NewReceptorBBS(etcdAdapter, consulSession, *taskHandlerAddress, clock.NewClock(), logger)
}
示例5: 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
}
示例6: initializeNatsEmitter
func initializeNatsEmitter(natsClient diegonats.NATSClient, logger lager.Logger) nats_emitter.NATSEmitter {
workPool, err := workpool.NewWorkPool(*routeEmittingWorkers)
if err != nil {
logger.Fatal("failed-to-construct-nats-emitter-workpool", err, lager.Data{"num-workers": *routeEmittingWorkers}) // should never happen
}
return nats_emitter.New(natsClient, workPool, logger)
}
示例7: storeAdapterProvider
func storeAdapterProvider(urls []string, concurrentRequests int) storeadapter.StoreAdapter {
workPool, err := workpool.NewWorkPool(concurrentRequests)
if err != nil {
panic(err)
}
return etcdstoreadapter.NewETCDStoreAdapter(urls, workPool)
}
示例8: 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
}
示例9: 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(),
workpool.NewWorkPool(coordinator.Conf.StoreMaxConcurrentRequests))
err := coordinator.StoreAdapter.Connect()
Ω(err).ShouldNot(HaveOccurred())
}
示例10: 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
}
示例11: StartETCD
func (coordinator *MCATCoordinator) StartETCD() {
etcdPort := 5000 + (coordinator.ParallelNode-1)*10
coordinator.StoreRunner = etcdstorerunner.NewETCDClusterRunner(etcdPort, 1, nil)
coordinator.StoreRunner.Start()
pool, err := workpool.NewWorkPool(coordinator.Conf.StoreMaxConcurrentRequests)
Expect(err).NotTo(HaveOccurred())
coordinator.StoreAdapter, err = etcdstoreadapter.New(&etcdstoreadapter.ETCDOptions{ClusterUrls: coordinator.StoreRunner.NodeURLS()}, pool)
Expect(err).NotTo(HaveOccurred())
err = coordinator.StoreAdapter.Connect()
Expect(err).NotTo(HaveOccurred())
}
示例12: NewClientProvider
func NewClientProvider(
totalCapacity executor.ExecutorResources,
allocationStore AllocationStore,
gardenStore GardenStore,
eventHub event.Hub,
lockManager keyed_lock.LockManager,
workPoolSettings executor.WorkPoolSettings,
) (executor.ClientProvider, error) {
creationWorkPool, err := workpool.NewWorkPool(workPoolSettings.CreateWorkPoolSize)
if err != nil {
return nil, err
}
deletionWorkPool, err := workpool.NewWorkPool(workPoolSettings.DeleteWorkPoolSize)
if err != nil {
return nil, err
}
readWorkPool, err := workpool.NewWorkPool(workPoolSettings.ReadWorkPoolSize)
if err != nil {
return nil, err
}
metricsWorkPool, err := workpool.NewWorkPool(workPoolSettings.MetricsWorkPoolSize)
if err != nil {
return nil, err
}
return &clientProvider{
totalCapacity: totalCapacity,
allocationStore: allocationStore,
gardenStore: gardenStore,
eventHub: eventHub,
containerLockManager: lockManager,
resourcesLock: new(sync.Mutex),
creationWorkPool: creationWorkPool,
deletionWorkPool: deletionWorkPool,
readWorkPool: readWorkPool,
metricsWorkPool: metricsWorkPool,
healthy: true,
}, nil
}
示例13: NewETCD
func NewETCD(nodeURLs []string, maxWorkers uint) (*etcd, error) {
workpool, err := workpool.NewWorkPool(int(maxWorkers))
if err != nil {
return nil, err
}
storeAdapter, err := etcdstoreadapter.New(&etcdstoreadapter.ETCDOptions{ClusterUrls: nodeURLs}, workpool)
if err != nil {
return nil, err
}
return &etcd{
storeAdapter: storeAdapter,
}, nil
}
示例14: Run
func (twp *TaskCompletionWorkPool) Run(signals <-chan os.Signal, ready chan<- struct{}) error {
cbWorkPool, err := workpool.NewWorkPool(twp.maxWorkers)
if err != nil {
twp.logger.Error("callback-workpool-creation-failed", err)
return err
}
twp.callbackWorkPool = cbWorkPool
close(ready)
<-signals
go twp.callbackWorkPool.Stop()
return nil
}
示例15: 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
}