RemoveClientFor removes the client with the specified address
(addr string)
| 117 | |
| 118 | // RemoveClientFor removes the client with the specified address |
| 119 | func (p *Pool) RemoveClientFor(addr string) { |
| 120 | p.Lock() |
| 121 | defer p.Unlock() |
| 122 | client, ok := p.clients[addr] |
| 123 | if ok { |
| 124 | delete(p.clients, addr) |
| 125 | if p.clientsMetric != nil { |
| 126 | p.clientsMetric.Add(-1) |
| 127 | } |
| 128 | // Close in the background since this operation may take awhile and we have a mutex |
| 129 | go func(addr string, closer PoolClient) { |
| 130 | if err := closer.Close(); err != nil { |
| 131 | level.Error(p.logger).Log("msg", fmt.Sprintf("error closing connection to %s", p.clientName), "addr", addr, "err", err) |
| 132 | } |
| 133 | }(addr, client) |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // RegisteredAddresses returns all the service addresses for which there's an active client. |
| 138 | func (p *Pool) RegisteredAddresses() []string { |