pub struct CircuitBreaker { /* private fields */ }Expand description
Circuit breaker for multiple domains
Implementations§
Source§impl CircuitBreaker
impl CircuitBreaker
Sourcepub fn new(config: CircuitBreakerConfig) -> Self
pub fn new(config: CircuitBreakerConfig) -> Self
Create new circuit breaker
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
Create with default config
Sourcepub fn allow_request(&self, domain: &str) -> bool
pub fn allow_request(&self, domain: &str) -> bool
Check if a request to this domain is allowed
Sourcepub fn record_success(&self, domain: &str)
pub fn record_success(&self, domain: &str)
Record a successful request
Sourcepub fn record_failure(&self, domain: &str)
pub fn record_failure(&self, domain: &str)
Record a failed request
Sourcepub fn record_timeout(&self, domain: &str)
pub fn record_timeout(&self, domain: &str)
Record a timeout (may or may not count as failure based on config)
Sourcepub fn record_server_error(&self, domain: &str)
pub fn record_server_error(&self, domain: &str)
Record a server error (5xx)
Sourcepub fn record_rate_limit(&self, domain: &str)
pub fn record_rate_limit(&self, domain: &str)
Record a rate limit (429)
Sourcepub fn get_state(&self, domain: &str) -> CircuitState
pub fn get_state(&self, domain: &str) -> CircuitState
Get circuit state for a domain
Sourcepub fn get_open_circuits(&self) -> Vec<String>
pub fn get_open_circuits(&self) -> Vec<String>
Get all open circuits (for monitoring)
Sourcepub fn stats(&self) -> CircuitBreakerStats
pub fn stats(&self) -> CircuitBreakerStats
Get circuit statistics
Auto Trait Implementations§
impl !Freeze for CircuitBreaker
impl RefUnwindSafe for CircuitBreaker
impl Send for CircuitBreaker
impl Sync for CircuitBreaker
impl Unpin for CircuitBreaker
impl UnwindSafe for CircuitBreaker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more