livery_client_circuit (livery v0.2.0)

View Source

Client layer: a circuit breaker.

Tracks the recent failure ratio for a named target. While the circuit is closed, requests pass and outcomes are tallied over a tumbling window; once the failure ratio reaches trip, the circuit opens and further requests fail fast with {error, circuit_open}. After cooldown ms the breaker half-opens to let one probe through, closing again on success or re-opening on failure. Add it with livery_client:circuit_breaker/1.

Opts: name (required), window (default 20), trip (default 0.5), cooldown ms (default 5000).

Summary

Functions

call(Req, Next, Opts)

-spec call(livery_client:request(), livery_client:next(), map()) ->
              {ok, livery_client:response()} | {error, term()}.