MCPcopy
hub / github.com/grafana/dskit / RemoveClient

Method RemoveClient

ring/client/pool.go:193–218  ·  view source on GitHub ↗

RemoveClient removes the client instance from the pool if it is still there and not cleaned up by health check. The value of client needs to be the same as returned by GetClientForInstance or GetClientFor. If addr is not empty and contains the same addr passed when obtaining the client, then the ope

(client PoolClient, addr string)

Source from the content-addressed store, hash-verified

191// The value of client needs to be the same as returned by GetClientForInstance or GetClientFor.
192// If addr is not empty and contains the same addr passed when obtaining the client, then the operation is sped up.
193func (p *Pool) RemoveClient(client PoolClient, addr string) {
194 p.Lock()
195 defer p.Unlock()
196 if addr != "" {
197 member, ok := p.members[addr]
198 if !ok {
199 return
200 }
201
202 if member.client != client {
203 return
204 }
205
206 delete(p.members, addr)
207 p.closeClient(addr, client)
208 return
209 }
210 for addr, member := range p.members {
211 if member.client != client {
212 continue
213 }
214 delete(p.members, addr)
215 p.closeClient(addr, client)
216 return
217 }
218}
219
220// RegisteredAddresses returns all the service addresses for which there's an active client.
221func (p *Pool) RegisteredAddresses() []string {

Callers 1

TestRemoveClientFunction · 0.95

Calls 1

closeClientMethod · 0.95

Tested by 1

TestRemoveClientFunction · 0.76