pub trait AsyncCircuitBreakerBackend: Send + Sync {
// Required methods
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 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 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 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 clear_open_at<'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 get_open_at<'life0, 'life1, 'async_trait>(
&'life0 self,
service: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Instant>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Async counterpart of CircuitBreakerBackend for distributed backends.
Implement this trait for backends that require genuine async I/O — e.g. Redis, etcd, or any network-based store — so they don’t need to embed their own blocking runtime.
InMemoryCircuitBreakerBackend implements this trait with trivially-async
wrappers for use in testing and single-process deployments.
Required Methods§
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.