Skip to main content

Breaker

Trait Breaker 

Source
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§

Source

fn tool_id(&self) -> &str

Opaque identifier the breaker guards — used in logs, audit, and the BreakerOpen error message.

Source

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.

Source

fn record_success<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Record a successful call against the guarded target.

Source

fn record_failure<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Record a failed call against the guarded target.

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>
where B: Breaker + ?Sized,

Source§

fn tool_id(&self) -> &str

Source§

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,

Source§

fn record_success<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<B>: 'async_trait,

Source§

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§

Source§

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).