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 } sp = &servicePool{ service: instance, pool: pools.NewResourcePool(getConnectionFactory(instance), c.Config.IdleConnectionsToInstance, c.Config.MaxConnectionsToInstance), } return }
func (p *Pool) addInstanceMux(s skynet.ServiceInfo) { if _, ok := p.servicePools[s.AddrString()]; !ok { sp := &servicePool{ service: s, pool: pools.NewResourcePool(func() (pools.Resource, error) { c, err := conn.NewConnection(s.Name, GetNetwork(), s.AddrString(), DIAL_TIMEOUT) if err == nil { c.SetIdleTimeout(getIdleTimeout(s)) } return c, err }, getIdleConnectionsToInstance(s), getMaxConnectionsToInstance(s)), } p.servicePools[s.AddrString()] = sp } else { p.UpdateInstance(s) } }