remove leaking logic in favor of recovery logic.

This commit is contained in:
Alex
2025-02-07 15:25:19 -05:00
committed by Cuong Manh Le
parent af4b826b68
commit 98042d8dbd
4 changed files with 174 additions and 246 deletions
+13
View File
@@ -145,3 +145,16 @@ func (p *prog) checkUpstream(upstream string, uc *ctrld.UpstreamConfig) {
time.Sleep(checkUpstreamBackoffSleep)
}
}
// countHealthy returns the number of upstreams in the provided map that are considered healthy.
func (um *upstreamMonitor) countHealthy(upstreams []string) int {
var count int
um.mu.RLock()
defer um.mu.RUnlock()
for _, upstream := range upstreams {
if !um.isDown(upstream) {
count++
}
}
return count
}