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


Golang pools.NewResourcePool函數代碼示例

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


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

示例1: buildPools

func (this *pubPool) buildPools() {
	// idleTimeout=0 means each kafka conn will last forever
	this.syncPool = pool.NewResourcePool(this.syncProducerFactory,
		this.size, this.size, 0)
	this.syncAllPool = pool.NewResourcePool(this.syncAllProducerFactory,
		30, 30, 0) // should be enough TODO
	this.asyncPool = pool.NewResourcePool(this.asyncProducerFactory,
		this.size, this.size, 0)
}
開發者ID:chendx79,項目名稱:gafka,代碼行數:9,代碼來源:pubpool.go

示例2: Open

// Open must be call before starting to use the pool.
func (cp *ConnectionPool) Open(connFactory CreateConnectionFunc) {
	cp.mu.Lock()
	defer cp.mu.Unlock()
	f := func() (pools.Resource, error) {
		return connFactory(cp)
	}
	cp.connections = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
}
開發者ID:xujianhai,項目名稱:vitess,代碼行數:9,代碼來源:connection_pool.go

示例3: newPool

func newPool(server string) *pools.ResourcePool {
	f := func() (pools.Resource, error) {
		c, err := redis.Dial("tcp", server)
		return &resourceConn{c}, err
	}

	cap := redisConnParams()

	return pools.NewResourcePool(f, cap, redisMaxCap, time.Minute)
}
開發者ID:xmikus01,項目名稱:fibrous,代碼行數:10,代碼來源:redis.go

示例4: Open

// Open must be called before starting to use the pool.
func (cp *ConnPool) Open(appParams, dbaParams *sqldb.ConnParams) {
	cp.mu.Lock()
	defer cp.mu.Unlock()

	f := func() (pools.Resource, error) {
		return NewDBConn(cp, appParams, dbaParams, cp.queryServiceStats)
	}
	cp.connections = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
	cp.dbaPool.Open(dbconnpool.DBConnectionCreator(dbaParams, cp.queryServiceStats.MySQLStats))
}
開發者ID:littleyang,項目名稱:vitess,代碼行數:11,代碼來源:connpool.go

示例5: Open

func (cp *ConnectionPool) Open(connFactory CreateConnectionFunc) {
	f := func() (pools.Resource, error) {
		c, err := connFactory()
		if err != nil {
			return nil, err
		}
		return &pooledConnection{c, cp}, nil
	}
	cp.pool = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
}
開發者ID:CERN-Stage-3,項目名稱:vitess,代碼行數:10,代碼來源:conn_pool.go

示例6: Open

func (cp *CachePool) Open(connFactory CreateCacheFunc) {
	if connFactory == nil {
		return
	}
	f := func() (pools.Resource, error) {
		c, err := connFactory()
		if err != nil {
			return nil, err
		}
		return &Cache{c, cp}, nil
	}
	cp.pool = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
}
開發者ID:shrutip,項目名稱:vitess,代碼行數:13,代碼來源:cache_pool.go

示例7: Open

func (cp *CachePool) Open() {
	if len(cp.commandLine) == 0 {
		log.Infof("rowcache not enabled")
		return
	}
	cp.startMemcache()
	log.Infof("rowcache is enabled")
	f := func() (pools.Resource, error) {
		c, err := memcache.Connect(cp.port)
		if err != nil {
			return nil, err
		}
		return &Cache{c, cp}, nil
	}
	cp.pool = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:16,代碼來源:cache_pool.go

示例8: Open

func (cp *CachePool) Open() {
	if cp.rowCacheConfig.Binary == "" {
		panic(NewTabletError(FATAL, "rowcache binary not specified"))
	}
	cp.startMemcache()
	log.Infof("rowcache is enabled")
	f := func() (pools.Resource, error) {
		return memcache.Connect(cp.port, 10*time.Second)
	}
	cp.mu.Lock()
	defer cp.mu.Unlock()
	cp.pool = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
	if cp.memcacheStats != nil {
		cp.memcacheStats.Open()
	}
}
開發者ID:chinna1986,項目名稱:vitess,代碼行數:16,代碼來源:cache_pool.go

示例9: Open

func (cp *CachePool) Open() {
	if cp.rowCacheConfig.Binary == "" {
		log.Infof("rowcache not enabled")
		return
	}
	cp.startMemcache()
	log.Infof("rowcache is enabled")
	f := func() (pools.Resource, error) {
		c, err := memcache.Connect(cp.port)
		if err != nil {
			return nil, err
		}
		return &Cache{c, cp}, nil
	}
	cp.mu.Lock()
	defer cp.mu.Unlock()
	cp.pool = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
	if cp.memcacheStats != nil {
		cp.memcacheStats.Open()
	}
}
開發者ID:rjammala,項目名稱:vitess,代碼行數:21,代碼來源:cache_pool.go

示例10: Open

// Open opens the pool. It launches memcache and waits till it's up.
func (cp *CachePool) Open() {
	cp.mu.Lock()
	defer cp.mu.Unlock()
	if cp.pool != nil {
		panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "rowcache is already open"))
	}
	if cp.rowCacheConfig.Binary == "" {
		panic(NewTabletError(ErrFatal, vtrpc.ErrorCode_INTERNAL_ERROR, "rowcache binary not specified"))
	}
	cp.socket = generateFilename(cp.rowCacheConfig.Socket)
	cp.startCacheService()
	log.Infof("rowcache is enabled")
	f := func() (pools.Resource, error) {
		return cacheservice.Connect(cacheservice.Config{
			Address: cp.socket,
			Timeout: 10 * time.Second,
		})
	}
	cp.pool = pools.NewResourcePool(f, cp.capacity, cp.capacity, cp.idleTimeout)
	if cp.memcacheStats != nil {
		cp.memcacheStats.Open()
	}
}
開發者ID:fengshao0907,項目名稱:vitess,代碼行數:24,代碼來源:cache_pool.go

示例11: newRedisPool

func newRedisPool(uri string, capacity int, maxCapacity int, idleTimout time.Duration) *pools.ResourcePool {
	return pools.NewResourcePool(newRedisFactory(uri), capacity, maxCapacity, idleTimout)
}
開發者ID:sergeylanzman,項目名稱:goworker,代碼行數:3,代碼來源:redis.go

示例12: NewPool

// NewPool returns a new short service client pool
func NewPool(addr AddressFunc, capacity, maxCap int, connectionTimeout, idleTimeout time.Duration) (*Pool, error) {
	p := pools.NewResourcePool(createFactoryFunc(addr, connectionTimeout), capacity, maxCap, idleTimeout)

	return &Pool{p}, nil
}
開發者ID:DanielHeckrath,項目名稱:short,代碼行數:6,代碼來源:client.go


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