Skip to main content

Module circuit_breaker

Module circuit_breaker 

Source
Expand description

§Circuit Breaker State Machine

Per-model circuit breaker with sliding-window failure tracking, three-state FSM, and a CircuitBreakerRegistry keyed by model name.

§States

Closed ──(failure_rate > threshold)──> Open
Open   ──(timeout elapsed)──────────> HalfOpen
HalfOpen ──(success_threshold met)──> Closed
HalfOpen ──(any failure)────────────> Open

§Example

use tokio_prompt_orchestrator::circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};

let cfg = CircuitBreakerConfig::default();
let cb = CircuitBreaker::new(cfg);

assert!(cb.is_allowed());
cb.record_failure();

Structs§

CircuitBreaker
A single per-model circuit breaker.
CircuitBreakerConfig
Configuration for a CircuitBreaker.
CircuitBreakerRegistry
A registry of circuit breakers keyed by model name.

Enums§

CircuitState
Current state of a circuit breaker.