healthCheckLoop runs the periodic health check in a goroutine.
()
| 240 | |
| 241 | // healthCheckLoop runs the periodic health check in a goroutine. |
| 242 | func (cc *ClusterClient) healthCheckLoop() { |
| 243 | cc.mu.RLock() |
| 244 | ticker := cc.healthTicker |
| 245 | stop := cc.healthStop |
| 246 | cc.mu.RUnlock() |
| 247 | |
| 248 | if ticker == nil || stop == nil { |
| 249 | return |
| 250 | } |
| 251 | |
| 252 | for { |
| 253 | select { |
| 254 | case <-stop: |
| 255 | return |
| 256 | case <-ticker.C: |
| 257 | cc.performHealthCheck() |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | // performHealthCheck pings the active node and triggers failover if unreachable. |
| 263 | func (cc *ClusterClient) performHealthCheck() { |
no test coverage detected