pub struct BackoffState { /* private fields */ }Expand description
Mutable state tracker for an individual service’s backoff history.
One BackoffState instance is maintained per supervised service inside
the Supervisor.
Implementations§
Source§impl BackoffState
impl BackoffState
Sourcepub fn new(config: BackoffConfig) -> Self
pub fn new(config: BackoffConfig) -> Self
Create a fresh backoff state with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default configuration.
Sourcepub fn record_start(&mut self)
pub fn record_start(&mut self)
Record that the service has started (or restarted) successfully.
Called by the supervisor when a service’s run() method is entered.
Sourcepub fn maybe_reset_on_cooldown(&mut self)
pub fn maybe_reset_on_cooldown(&mut self)
Check if the cooldown period has elapsed since the last start, and if so, reset the attempt counter.
Called by the supervisor when a service exits so a service that ran healthily for a long time doesn’t carry old failure history into its next restart.
Sourcepub fn next_backoff(&mut self) -> BackoffAction
pub fn next_backoff(&mut self) -> BackoffAction
Record a failure and compute the next action.
Sourcepub fn recent_failures(&self) -> usize
pub fn recent_failures(&self) -> usize
Number of failures recorded within the circuit-breaker window.
Trait Implementations§
Source§impl Clone for BackoffState
impl Clone for BackoffState
Source§fn clone(&self) -> BackoffState
fn clone(&self) -> BackoffState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BackoffState
impl RefUnwindSafe for BackoffState
impl Send for BackoffState
impl Sync for BackoffState
impl Unpin for BackoffState
impl UnsafeUnpin for BackoffState
impl UnwindSafe for BackoffState
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