当前位置: 首页>>代码示例>>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;未经允许,请勿转载。