aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy/healthchecks.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2019-09-03 19:06:54 -0600
committerMatthew Holt <[email protected]>2019-09-03 19:06:54 -0600
commitacb8f0e0c26acd95cbee8981469b4ac62535d164 (patch)
tree3a7811603e82178df48cb9bab6c89e9a208bda8f /modules/caddyhttp/reverseproxy/healthchecks.go
parent652460e03e11a037d9f86b09b3546c9e42733d2d (diff)
downloadcaddy-acb8f0e0c26acd95cbee8981469b4ac62535d164.tar.gz
caddy-acb8f0e0c26acd95cbee8981469b4ac62535d164.zip
Integrate circuit breaker modules with reverse proxy
Diffstat (limited to 'modules/caddyhttp/reverseproxy/healthchecks.go')
-rw-r--r--modules/caddyhttp/reverseproxy/healthchecks.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/healthchecks.go b/modules/caddyhttp/reverseproxy/healthchecks.go
index 0b46d04e4..673f7c4dd 100644
--- a/modules/caddyhttp/reverseproxy/healthchecks.go
+++ b/modules/caddyhttp/reverseproxy/healthchecks.go
@@ -64,6 +64,14 @@ type PassiveHealthChecks struct {
UnhealthyLatency caddy.Duration `json:"unhealthy_latency,omitempty"`
}
+// CircuitBreaker is a type that can act as an early-warning
+// system for the health checker when backends are getting
+// overloaded.
+type CircuitBreaker interface {
+ OK() bool
+ RecordMetric(statusCode int, latency time.Duration)
+}
+
// activeHealthChecker runs active health checks on a
// regular basis and blocks until
// h.HealthChecks.Active.stopChan is closed.
@@ -202,7 +210,7 @@ func (h *Handler) doActiveHealthCheck(hostAddr string, host Host) error {
// remembers 1 failure for upstream for the configured
// duration. If passive health checks are disabled or
// failure expiry is 0, this is a no-op.
-func (h Handler) countFailure(upstream *Upstream) {
+func (h *Handler) countFailure(upstream *Upstream) {
// only count failures if passive health checking is enabled
// and if failures are configured have a non-zero expiry
if h.HealthChecks == nil || h.HealthChecks.Passive == nil {