Skip to main content

Module failover

Module failover 

Source
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

  1. Request arrives targeting api/search
  2. Request is forwarded to the api backend
  3. If api returns an error, the request is retried against api-backup/search
  4. If api-backup also fails, the request is retried against api-backup-2/search
  5. Failover backend tools are hidden from ListTools (like canary backends)

Structs§

FailoverLayer
Tower layer that produces a FailoverService.
FailoverService
Tower service that fails over to secondary backends on primary error.