Example #1
0
func NewRPCPool(n int, ttl time.Duration,
	endpoint string, rpcEndpoints []string) (res *RPCPool) {
	res = &RPCPool{
		endpoint: endpoint,
		timeout:  ttl,
	}
	res.ResourcePool = pools.NewResourcePool(res.factory, n, n, ttl)
	return
}
Example #2
0
func NewTPool(endpoints []string, bufferSize int, n int, ttl time.Duration) (res *TPool) {
	res = &TPool{
		endpoints:        endpoints,
		endpointsCap:     len(endpoints) - 1,
		ttl:              ttl,
		transportFactory: thrift.NewTBufferedTransportFactory(bufferSize),
		protoFactory:     thrift.NewTBinaryProtocolFactoryDefault(),
	}
	res.ResourcePool = pools.NewResourcePool(res.factory, n, n, ttl)
	return
}
Example #3
0
/*
 * Creats an instance of pool
   Params:
     connect: A callback which creates a connection to datastore
     instace: An instance of backend(redis instance)
     settings: configurations needed to create a pool
*/
func NewPool(connect dialAndConnect, instance interface{}, settings PoolSettings) *ResourcePool {
	return &ResourcePool{
		pools.NewResourcePool(newRedisFactory(connect, instance),
			settings.Capacity, settings.MaxCapacity, settings.Timeout)}
}