pub struct ConsecutiveErrorTracker { /* private fields */ }Expand description
Tracks consecutive errors to prevent infinite retry loops.
If a loop encounters max_consecutive errors without a single
success, it should pause for pause_duration before retrying.
Implementations§
Source§impl ConsecutiveErrorTracker
impl ConsecutiveErrorTracker
Sourcepub fn new(max_consecutive: u32, pause_duration: Duration) -> Self
pub fn new(max_consecutive: u32, pause_duration: Duration) -> Self
Create a new tracker.
max_consecutive: Number of consecutive errors before pausing.pause_duration: How long to pause after hitting the limit.
Sourcepub fn record_error(&mut self) -> bool
pub fn record_error(&mut self) -> bool
Record an error. Returns true if the loop should pause.
Sourcepub fn record_success(&mut self)
pub fn record_success(&mut self)
Record a success, resetting the counter.
Sourcepub fn should_pause(&self) -> bool
pub fn should_pause(&self) -> bool
Whether the loop should pause due to too many consecutive errors.
Sourcepub fn pause_duration(&self) -> Duration
pub fn pause_duration(&self) -> Duration
How long to pause.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConsecutiveErrorTracker
impl RefUnwindSafe for ConsecutiveErrorTracker
impl Send for ConsecutiveErrorTracker
impl Sync for ConsecutiveErrorTracker
impl Unpin for ConsecutiveErrorTracker
impl UnsafeUnpin for ConsecutiveErrorTracker
impl UnwindSafe for ConsecutiveErrorTracker
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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