cleanUnhealthy loops through all servers and deletes any that fails a healthcheck.
()
| 175 | |
| 176 | // cleanUnhealthy loops through all servers and deletes any that fails a healthcheck. |
| 177 | func (p *Pool) cleanUnhealthy() { |
| 178 | for _, addr := range p.RegisteredAddresses() { |
| 179 | client, ok := p.fromCache(addr) |
| 180 | // not ok means someone removed a client between the start of this loop and now |
| 181 | if ok { |
| 182 | err := healthCheck(client, p.cfg.HealthCheckTimeout) |
| 183 | if err != nil { |
| 184 | level.Warn(p.logger).Log("msg", fmt.Sprintf("removing %s failing healthcheck", p.clientName), "addr", addr, "reason", err) |
| 185 | p.RemoveClientFor(addr) |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // healthCheck will check if the client is still healthy, returning an error if it is not |
| 192 | func healthCheck(client PoolClient, timeout time.Duration) error { |