pub struct InMemoryCircuitBreakerBackend { /* private fields */ }Expand description
In-process circuit breaker backend backed by a Mutex<HashMap>.
Each service name gets its own independent failure counter and open-at
timestamp. Multiple CircuitBreaker instances that share the same
backend (via CircuitBreaker::with_backend) will correctly track
failures per service rather than sharing a single counter.
Implementations§
Trait Implementations§
Source§impl AsyncCircuitBreakerBackend for InMemoryCircuitBreakerBackend
impl AsyncCircuitBreakerBackend for InMemoryCircuitBreakerBackend
Source§fn increment_failures<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_failures<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Increment the consecutive failure count and return the new count.
Source§fn reset_failures<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reset_failures<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reset the consecutive failure count to zero.
Source§fn get_failures<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_failures<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = u32> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return the current consecutive failure count.
Source§fn set_open_at<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
at: Instant,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_open_at<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
at: Instant,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Record the instant at which the circuit was opened.
Source§impl CircuitBreakerBackend for InMemoryCircuitBreakerBackend
impl CircuitBreakerBackend for InMemoryCircuitBreakerBackend
Source§fn 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.Source§fn reset_failures(&self, service: &str)
fn reset_failures(&self, service: &str)
Reset the consecutive failure count for
service to zero.Source§fn get_failures(&self, service: &str) -> u32
fn get_failures(&self, service: &str) -> u32
Return the current consecutive failure count for
service.Source§fn 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.Source§fn 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.
Auto Trait Implementations§
impl Freeze for InMemoryCircuitBreakerBackend
impl RefUnwindSafe for InMemoryCircuitBreakerBackend
impl Send for InMemoryCircuitBreakerBackend
impl Sync for InMemoryCircuitBreakerBackend
impl Unpin for InMemoryCircuitBreakerBackend
impl UnsafeUnpin for InMemoryCircuitBreakerBackend
impl UnwindSafe for InMemoryCircuitBreakerBackend
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