pub struct CircuitBreaker { /* private fields */ }Expand description
Counts consecutive hard failures and trips open after a threshold.
G28-D (v1.0.68): caps enrich --retry-failed and ingest --retry-failed
loops so persistent failures (e.g., LLM provider returning the same
4xx for hours) cannot run unbounded. After threshold consecutive
AttemptOutcome::HardFailure outcomes, record returns true and
the caller is expected to abort with AppError::CircuitBreakerOpen.
Rate-limited / transient errors are explicitly NOT counted, so a provider that throttles but eventually recovers will not trip the breaker.
Implementations§
Source§impl CircuitBreaker
impl CircuitBreaker
Sourcepub fn new(threshold: u32, cooldown: Duration) -> Self
pub fn new(threshold: u32, cooldown: Duration) -> Self
Creates a breaker that opens after threshold consecutive hard
failures and stays open for cooldown after the last failure.
Sourcepub fn record(&mut self, outcome: AttemptOutcome) -> bool
pub fn record(&mut self, outcome: AttemptOutcome) -> bool
Records one attempt outcome.
Returns true when the breaker is now open and the caller must
abort the job. Returns false when the attempt should continue.
Trait Implementations§
Source§impl Clone for CircuitBreaker
impl Clone for CircuitBreaker
Source§fn clone(&self) -> CircuitBreaker
fn clone(&self) -> CircuitBreaker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CircuitBreaker
impl RefUnwindSafe for CircuitBreaker
impl Send for CircuitBreaker
impl Sync for CircuitBreaker
impl Unpin for CircuitBreaker
impl UnsafeUnpin for CircuitBreaker
impl UnwindSafe for CircuitBreaker
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more