Expand description
Circuit breaker pattern for sync-engine protection.
Prevents cascading failures when sync-engine is overloaded or unhealthy.
Uses the recloser crate following sync-engine’s proven patterns.
§States
- Closed: Normal operation, requests pass through
- Open: Sync-engine unhealthy, requests fail-fast without attempting
- HalfOpen: Testing if sync-engine recovered, limited requests allowed
§Usage
let circuit = SyncEngineCircuit::new();
// Wrap sync-engine write calls
match circuit.writes.call(|| async { Ok::<(), String>(()) }).await {
Ok(()) => { /* success */ }
Err(CircuitError::Rejected) => { /* circuit open, backoff */ }
Err(CircuitError::Inner(e)) => { /* sync-engine error */ }
}Structs§
- Circuit
Breaker - A named circuit breaker with metrics tracking.
- Circuit
Config - Configuration for a circuit breaker.
- Sync
Engine Circuit - Circuit breaker specifically for sync-engine operations.
- Sync
Engine Circuit Metrics - Aggregated metrics from sync-engine circuits.
Enums§
- Circuit
Error - Error type for circuit-protected operations.
- Circuit
State - Circuit breaker state for metrics/monitoring.