Expand description
Reliability tier: retry with backoff + jitter, circuit breaker. Reliability tier: backpressure (bounded backend concurrency), retry with exponential backoff + jitter, and a closed/open/half-open circuit breaker around backend operations.
All three are composed by a private ReliableBackend decorator around any
crate::backend::Backend, applied by the builder when a ReliabilityConfig is set
(see crate::CacheKitBuilder::reliability). The intent presets
production, encrypted, and io enable it by default; minimal does
not — mirroring the TypeScript SDK’s preset posture.
Composition order is backpressure(breaker(retry(op))):
- The retry loop is inside the breaker (matching the TypeScript SDK’s
ReliabilityExecutor), so one exhausted retry sequence counts as a single breaker failure, and a fast-failing open breaker never spends time retrying. - The concurrency limiter is outermost: one permit per logical cache operation, held across the entire breaker/retry sequence. That bounds in-flight work including retry amplification (K callers mid-backoff are still K permits — new work queues behind them instead of piling onto a struggling backend), and a shed call never touches breaker counters or half-open probe slots, so the breaker keeps measuring backend health, not caller-side overload. A permit holder never re-enters the limiter (backend ops don’t nest), so holding permits across retry backoff cannot deadlock.
Unlike the TypeScript breaker (which counts every error), only errors
classified retryable by crate::error::BackendErrorKind::is_retryable (Transient,
Timeout) count toward opening the circuit: they are the backend-health
signals. Permanent / Authentication errors are request-specific — five
malformed requests must not cut off healthy traffic.
Requires a tokio runtime for backoff timers (redis and cachekitio
backends already do). Not available on wasm32 targets.
Structs§
- Backpressure
Config - Backpressure configuration: bound how many backend data operations may be in flight at once, so a slow or failing backend cannot exhaust the caller’s connection pool or memory.
- Circuit
Breaker Config - Circuit breaker configuration.
- Reliability
Config - Reliability stack configuration: which layers to apply around backend ops.
- Retry
Config - Retry policy configuration (truncated exponential backoff with jitter).