package main import ( "log" "net/http" "time" ) // startHealthCheck runs a periodic health check against the WAF. // It updates the circuit breaker based on WAF reachability. func startHealthCheck() { go func() { for { cfg := getConfig() interval := time.Duration(cfg.HealthInterval) * time.Second if interval < 1*time.Second { interval = 5 * time.Second } client := &http.Client{Timeout: 2 * time.Second} resp, err := client.Head(cfg.WAFURL + "/") if err != nil { log.Printf("WAF health check FAILED: %v", err) breaker.RecordFailure() } else { resp.Body.Close() breaker.RecordSuccess() } time.Sleep(interval) } }() }