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
impl RestartParams
sourcepub fn new(min_backoff: Duration, max_backoff: Duration) -> Self
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
sourcepub fn auto_reset(self, auto_reset: impl Into<Option<Duration>>) -> Self
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.
sourcepub fn factor(self, factor: impl Into<Option<f64>>) -> Self
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.
sourcepub fn max_retries(self, max_retries: impl Into<Option<NonZeroU64>>) -> Self
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
impl Clone for RestartParams
source§fn clone(&self) -> RestartParams
fn clone(&self) -> RestartParams
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RestartParams
impl Debug for RestartParams
source§impl PartialEq for RestartParams
impl PartialEq for RestartParams
source§fn eq(&self, other: &RestartParams) -> bool
fn eq(&self, other: &RestartParams) -> bool
self
and other
values to be equal, and is used
by ==
.