pub trait Breaker: Send + Sync {
// Required methods
fn tool_id(&self) -> &str;
fn is_open<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn record_success<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn record_failure<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
The circuit-breaker contract callers depend on, so resilience consumers
(backends::resilient_send, the per-tool registry, tests) can be written
against the behaviour rather than the concrete CircuitBreaker struct —
the SOLID dependency-inversion seam for the breaker.
This is the full lifecycle contract (gate + record both outcomes);
intent::BreakerCheck is the narrower cross-crate read-only seam the
capability router and retry use to gate on is_open alone.
The blanket Breaker impl on Arc<B> lets a shared Arc<CircuitBreaker>
be passed wherever &impl Breaker is expected without a manual deref.
Required Methods§
Sourcefn tool_id(&self) -> &str
fn tool_id(&self) -> &str
Opaque identifier the breaker guards — used in logs, audit, and the
BreakerOpen error message.
Sourcefn is_open<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn is_open<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
true only when the breaker is actively rejecting calls. May
transparently drive Open → HalfOpen once the cooldown elapses.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<B> Breaker for Arc<B>
impl<B> Breaker for Arc<B>
fn tool_id(&self) -> &str
fn is_open<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
Arc<B>: 'async_trait,
fn record_success<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Arc<B>: 'async_trait,
fn record_failure<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
Arc<B>: 'async_trait,
Implementors§
impl Breaker for CircuitBreaker
The concrete breaker is the canonical Breaker implementation; the
trait methods delegate to the inherent ones (which take method-resolution
priority, so existing concrete callers are unaffected).