mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 09:40:13 +08:00
Implement success ratio in health checks
This commit is contained in:
parent
2c61b50b5f
commit
6d010189a5
|
@ -84,6 +84,15 @@ func (u *Upstream) Healthy() bool {
|
||||||
if healthy && u.healthCheckPolicy != nil {
|
if healthy && u.healthCheckPolicy != nil {
|
||||||
healthy = u.Host.Fails() < u.healthCheckPolicy.MaxFails
|
healthy = u.Host.Fails() < u.healthCheckPolicy.MaxFails
|
||||||
}
|
}
|
||||||
|
if healthy && u.healthCheckPolicy != nil &&
|
||||||
|
u.healthCheckPolicy.MinSuccessRatio > 0 {
|
||||||
|
successes := u.Host.Successes()
|
||||||
|
if successes >= u.healthCheckPolicy.MinSuccesses {
|
||||||
|
fails := u.Host.Fails()
|
||||||
|
healthRatio := float64(fails) / float64(successes)
|
||||||
|
healthy = healthRatio < (1 - float64(u.healthCheckPolicy.MinSuccessRatio))
|
||||||
|
}
|
||||||
|
}
|
||||||
if healthy && u.cb != nil {
|
if healthy && u.cb != nil {
|
||||||
healthy = u.cb.OK()
|
healthy = u.cb.OK()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user