pub enum StoreErrorPolicy {
FailOpen,
FailClosed,
}Expand description
What rate_limit_with_store does when the shared store itself errors
(e.g. a Redis outage) — distinct from the store returning a decision.
This is a call-site choice (the RateLimitStore
port documents the default as fail-open); pick FailClosed
for a deployment where losing the ceiling is worse than shedding load.
Variants§
FailOpen
Serve the request when the store errors. Abuse-dampening must not drop legitimate traffic on a limiter outage — the historical default and the port’s documented contract. The trade-off: while the store is down, every replica has lost its ceiling at once, so an auth/OTP endpoint runs unthrottled. The fail-open path is logged at ERROR (alertable), never hidden at WARN, so an operator sees the window it is exercised in.
FailClosed
Refuse with 503 Service Unavailable while the store is unavailable, so
the ceiling is never silently lifted. Correct for a service that fronts
authentication/OTP and would rather shed load than brute-force-expose it.