rust.circuit_breaker
Stability
High
Detects external service calls without circuit breaker protection.
Why It Matters
Section titled “Why It Matters”Missing circuit breakers:
- Cascade failures — One service down takes all down
- Resource exhaustion — Threads blocked on failing calls
- No recovery — System stays broken after transient issues
Example
Section titled “Example”// ❌ Before (no circuit breaker)async fn call_payment_service(payment: &Payment) -> Result<Receipt> { client.post("/charge").json(payment).send().await?}// ✅ After (with circuit breaker)use failsafe::{Config, CircuitBreaker, Error};
lazy_static! { static ref BREAKER: CircuitBreaker<(), Error> = Config::default() .failure_policy(consecutive_failures(5)) .build();}
async fn call_payment_service(payment: &Payment) -> Result<Receipt> { BREAKER.call(|| async { client.post("/charge").json(payment).send().await }).await?}What Unfault Detects
Section titled “What Unfault Detects”- HTTP clients without circuit breakers
- gRPC calls without protection
- Database connections without failover
Auto-Fix
Section titled “Auto-Fix”Unfault can add circuit breaker wrappers using failsafe or similar crates.