MCPcopy Create free account
hub / github.com/cortexproject/cortex / RemoveClientFor

Method RemoveClientFor

pkg/ring/client/pool.go:119–135  ·  view source on GitHub ↗

RemoveClientFor removes the client with the specified address

(addr string)

Source from the content-addressed store, hash-verified

117
118// RemoveClientFor removes the client with the specified address
119func (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.
138func (p *Pool) RegisteredAddresses() []string {

Callers 3

removeStaleClientsMethod · 0.95
cleanUnhealthyMethod · 0.95
TestPoolCacheFunction · 0.95

Calls 4

CloseMethod · 0.65
AddMethod · 0.45
LogMethod · 0.45
ErrorMethod · 0.45

Tested by 1

TestPoolCacheFunction · 0.76