mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
Add min_successes
This commit is contained in:
parent
c8b8c3a7b2
commit
2c61b50b5f
3 changed files with 29 additions and 0 deletions
|
@ -79,6 +79,7 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
|
||||||
// max_fails <num>
|
// max_fails <num>
|
||||||
// success_duration <duration>
|
// success_duration <duration>
|
||||||
// min_success_ratio <ratio>
|
// min_success_ratio <ratio>
|
||||||
|
// min_success <num>
|
||||||
// unhealthy_status <status>
|
// unhealthy_status <status>
|
||||||
// unhealthy_latency <duration>
|
// unhealthy_latency <duration>
|
||||||
// unhealthy_request_count <num>
|
// unhealthy_request_count <num>
|
||||||
|
@ -456,6 +457,22 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||||
}
|
}
|
||||||
h.HealthChecks.Passive.MinSuccessRatio = ratio
|
h.HealthChecks.Passive.MinSuccessRatio = ratio
|
||||||
|
|
||||||
|
case "min_successes":
|
||||||
|
if !d.NextArg() {
|
||||||
|
return d.ArgErr()
|
||||||
|
}
|
||||||
|
if h.HealthChecks == nil {
|
||||||
|
h.HealthChecks = new(HealthChecks)
|
||||||
|
}
|
||||||
|
if h.HealthChecks.Passive == nil {
|
||||||
|
h.HealthChecks.Passive = new(PassiveHealthChecks)
|
||||||
|
}
|
||||||
|
count, err := strconv.Atoi(d.Val())
|
||||||
|
if err != nil {
|
||||||
|
return d.Errf("invalid minimum success count '%s': %v", d.Val(), err)
|
||||||
|
}
|
||||||
|
h.HealthChecks.Passive.MinSuccesses = count
|
||||||
|
|
||||||
case "fail_duration":
|
case "fail_duration":
|
||||||
if !d.NextArg() {
|
if !d.NextArg() {
|
||||||
return d.ArgErr()
|
return d.ArgErr()
|
||||||
|
|
|
@ -127,6 +127,14 @@ type PassiveHealthChecks struct {
|
||||||
// must be configured for those stats to be counted. Default is 0 (no ratio).
|
// must be configured for those stats to be counted. Default is 0 (no ratio).
|
||||||
MinSuccessRatio caddyhttp.Ratio `json:"min_success_ratio,omitempty"`
|
MinSuccessRatio caddyhttp.Ratio `json:"min_success_ratio,omitempty"`
|
||||||
|
|
||||||
|
// The minimum number of successful requests before considering the
|
||||||
|
// minimum success ratio. Default is 5. Requires MinSuccessRatio >= 0.
|
||||||
|
//
|
||||||
|
// If there are less than this many successful requests, then the ratio is
|
||||||
|
// ignored, because of a lack of data. This ensures that the upstream isn't
|
||||||
|
// prematurely considered unhealthy because no requests have happened yet.
|
||||||
|
MinSuccesses int `json:"min_successes,omitempty"`
|
||||||
|
|
||||||
// Limits the number of simultaneous requests to a backend by
|
// Limits the number of simultaneous requests to a backend by
|
||||||
// marking the backend as "down" if it has this many concurrent
|
// marking the backend as "down" if it has this many concurrent
|
||||||
// requests or more.
|
// requests or more.
|
||||||
|
|
|
@ -352,6 +352,10 @@ func (h *Handler) Provision(ctx caddy.Context) error {
|
||||||
if h.HealthChecks.Passive.FailDuration > 0 && h.HealthChecks.Passive.MaxFails == 0 {
|
if h.HealthChecks.Passive.FailDuration > 0 && h.HealthChecks.Passive.MaxFails == 0 {
|
||||||
h.HealthChecks.Passive.MaxFails = 1
|
h.HealthChecks.Passive.MaxFails = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.HealthChecks.Passive.MinSuccessRatio > 0 && h.HealthChecks.Passive.MinSuccesses == 0 {
|
||||||
|
h.HealthChecks.Passive.MinSuccesses = 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if active health checks are enabled, configure them and start a worker
|
// if active health checks are enabled, configure them and start a worker
|
||||||
|
|
Loading…
Reference in a new issue