()
| 153 | } |
| 154 | |
| 155 | func (p *Pool) removeStaleClients() { |
| 156 | // Only if service discovery has been configured. |
| 157 | if p.discovery == nil { |
| 158 | return |
| 159 | } |
| 160 | |
| 161 | serviceAddrs, err := p.discovery() |
| 162 | if err != nil { |
| 163 | level.Error(p.logger).Log("msg", "error removing stale clients", "err", err) |
| 164 | return |
| 165 | } |
| 166 | |
| 167 | for _, addr := range p.RegisteredAddresses() { |
| 168 | if slices.Contains(serviceAddrs, addr) { |
| 169 | continue |
| 170 | } |
| 171 | level.Info(p.logger).Log("msg", "removing stale client", "addr", addr) |
| 172 | p.RemoveClientFor(addr) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // cleanUnhealthy loops through all servers and deletes any that fails a healthcheck. |
| 177 | func (p *Pool) cleanUnhealthy() { |
no test coverage detected