pub trait CircuitBreakerBackend: Send + Sync {
// Required methods
fn increment_failures(&self, service: &str) -> u32;
fn reset_failures(&self, service: &str);
fn get_failures(&self, service: &str) -> u32;
fn set_open_at(&self, service: &str, at: Instant);
fn clear_open_at(&self, service: &str);
fn get_open_at(&self, service: &str) -> Option<Instant>;
}Expand description
Backend for circuit breaker state storage.
Implement this trait to share circuit breaker state across processes
(e.g., via Redis). The in-process default is InMemoryCircuitBreakerBackend.
Note: Methods are synchronous to avoid pulling in async-trait. A
distributed backend (e.g., Redis) can internally spawn a Tokio runtime.
Required Methods§
Sourcefn increment_failures(&self, service: &str) -> u32
fn increment_failures(&self, service: &str) -> u32
Increment the consecutive failure count for service and return the new count.
Sourcefn reset_failures(&self, service: &str)
fn reset_failures(&self, service: &str)
Reset the consecutive failure count for service to zero.
Sourcefn get_failures(&self, service: &str) -> u32
fn get_failures(&self, service: &str) -> u32
Return the current consecutive failure count for service.
Sourcefn set_open_at(&self, service: &str, at: Instant)
fn set_open_at(&self, service: &str, at: Instant)
Record the instant at which the circuit was opened for service.
Sourcefn clear_open_at(&self, service: &str)
fn clear_open_at(&self, service: &str)
Clear the open-at timestamp, effectively moving the circuit to Closed or HalfOpen.
Sourcefn get_open_at(&self, service: &str) -> Option<Instant>
fn get_open_at(&self, service: &str) -> Option<Instant>
Return the instant at which the circuit was opened, or None if it is not open.