pub trait CircuitBreaker: Send + Sync {
// Required methods
fn check(&self) -> Result<(), BreakerError>;
fn record_success(&self);
fn record_failure(&self);
}Expand description
SDK owns this trait + DefaultCircuitBreaker; consumers implement it for
domain-specific traffic classes (A2A, HTTP, etc.). See
docs/oxicode-sdk-ownership.md.
This trait is #[unstable] initially — the surface may evolve as we
integrate with the agent loop and learn which signals consumers actually
need. It graduates to #[stable] after it proves useful in production.
Required Methods§
Sourcefn check(&self) -> Result<(), BreakerError>
fn check(&self) -> Result<(), BreakerError>
Returns Err(BreakerError::Open) if the circuit is open (calls should
fail-fast). The check is cheap (atomic load) so callers may invoke it
before every retry.
Sourcefn record_success(&self)
fn record_success(&self)
Record a successful call. Resets the failure count and, if the breaker
was in HalfOpen, returns it to Closed.
Sourcefn record_failure(&self)
fn record_failure(&self)
Record a failed call. Increments the failure count; if the count
reaches the configured threshold the breaker trips to Open.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".