Expand description
Backend failover middleware.
Routes requests to a primary backend, automatically falling over to
secondary backends when the primary returns an error. Multiple failover
backends can be configured per primary, ordered by priority
(lower values tried first).
§Configuration
[[backends]]
name = "api"
transport = "http"
url = "http://primary:8080"
[[backends]]
name = "api-backup"
transport = "http"
url = "http://secondary:8080"
failover_for = "api"
priority = 0 # tried first (default)
[[backends]]
name = "api-backup-2"
transport = "http"
url = "http://tertiary:8080"
failover_for = "api"
priority = 10 # tried second§How it works
- Request arrives targeting
api/search - Request is forwarded to the
apibackend - If
apireturns an error, the request is retried againstapi-backup/search - If
api-backupalso fails, the request is retried againstapi-backup-2/search - Failover backend tools are hidden from
ListTools(like canary backends)
Structs§
- Failover
Layer - Tower layer that produces a
FailoverService. - Failover
Service - Tower service that fails over to secondary backends on primary error.