Example #1
0
func (c *Client) getServicePool(instance *service.Service) (sp *servicePool) {
	servicePoolMutex.Lock()
	defer servicePoolMutex.Unlock()

	key := getInstanceKey(instance)

	var ok bool
	if sp, ok = c.servicePools[key]; ok {
		return
	}

	sp = &servicePool{
		service: instance,
		pool:    pools.NewResourcePool(getConnectionFactory(instance), c.Config.ConnectionPoolSize, c.Config.ConnectionPoolSize),
	}
	return
}
Example #2
0
func (c *Client) getServicePool(instance *skynet.ServiceInfo) (sp *servicePool) {
	servicePoolMutex.Lock()
	defer servicePoolMutex.Unlock()

	key := getInstanceKey(instance)

	var ok bool
	if sp, ok = c.servicePools[key]; ok {
		return
	}

	dbgf("making service pool, size = %d, %d\n", c.Config.IdleConnectionsToInstance, c.Config.MaxConnectionsToInstance)

	sp = &servicePool{
		service: instance,
		pool:    pools.NewResourcePool(getConnectionFactory(instance), c.Config.IdleConnectionsToInstance, c.Config.MaxConnectionsToInstance),
	}
	return
}