StartHealthCheck begins periodic health checking of the active node. If the active node becomes unreachable, it automatically triggers failover. The health check pings the /api2/json/version endpoint which is lightweight.
()
| 205 | // If the active node becomes unreachable, it automatically triggers failover. |
| 206 | // The health check pings the /api2/json/version endpoint which is lightweight. |
| 207 | func (cc *ClusterClient) StartHealthCheck() { |
| 208 | cc.mu.Lock() |
| 209 | defer cc.mu.Unlock() |
| 210 | |
| 211 | // Stop any existing health check |
| 212 | cc.stopHealthCheckLocked() |
| 213 | |
| 214 | cc.healthStop = make(chan struct{}) |
| 215 | cc.healthTicker = time.NewTicker(cc.healthInterval) |
| 216 | |
| 217 | go cc.healthCheckLoop() |
| 218 | |
| 219 | cc.logger.Info("[CLUSTER] Health check started (interval: %s)", cc.healthInterval) |
| 220 | } |
| 221 | |
| 222 | // StopHealthCheck stops the periodic health checking. |
| 223 | func (cc *ClusterClient) StopHealthCheck() { |
no test coverage detected