Struct elfo_core::RestartParams

source ·
pub struct RestartParams { /* private fields */ }
Expand description

Restart parameters for the backoff strategy when an actor restarts based on the RestartPolicy.

Implementations§

source§

impl RestartParams

source

pub fn new(min_backoff: Duration, max_backoff: Duration) -> Self

Creates a new instance with the specified minimum and maximum backoff durations. The default values for auto_reset, max_retries, and factor are set as follows:

  • auto_reset = min_backoff
  • max_retries = NonZeroU64::MAX
  • factor = 2.0
source

pub fn auto_reset(self, auto_reset: impl Into<Option<Duration>>) -> Self

Sets the duration deemed sufficient to consider an actor healthy. Once this duration elapses, the backoff strategy automatically resets, including retry counting, effectively treating the next attempt as the first retry. Therefore, setting the auto_reset to small values, such as Duration::ZERO, can result in the absence of a limit on the maximum number of retries. After the backoff strategy resets, the actor will restart immediately.

None does not change the auto_reset setting.

If the function isn’t used, auto_reset = min_backoff is used by default.

source

pub fn factor(self, factor: impl Into<Option<f64>>) -> Self

Sets the factor used to calculate the next backoff duration. The factor should be a finite value and should not be negative; otherwise, a warning will be emitted.

None value does not change the factor setting.

If the function isn’t used, factor = 2.0 is used by default.

source

pub fn max_retries(self, max_retries: impl Into<Option<NonZeroU64>>) -> Self

Sets the maximum number of allowed retries. Each time the actor restarts, it counts as a retry. If the retries reach the specified max_retries, the actor stops restarting. If the actor lives long enough to be considered healthy (see RestartParams::auto_reset), the restart count goes back to zero, and the next restart is considered the first retry again.

None does not change the max_retries setting.

If the function isn’t used, max_retries = NonZeroU64::MAX is used by default.

Trait Implementations§

source§

impl Clone for RestartParams

source§

fn clone(&self) -> RestartParams

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RestartParams

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for RestartParams

source§

fn eq(&self, other: &RestartParams) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for RestartParams

source§

impl StructuralPartialEq for RestartParams

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more