Struct RetryPolicy
pub struct RetryPolicy {
pub attempts: u32,
pub initial: Duration,
pub factor: f64,
pub max: Duration,
pub jitter: bool,
pub max_elapsed: Option<Duration>,
pub non_retryable: Vec<String>,
pub retry_if: Option<RetryIf>,
pub on_exhausted: Option<Exhausted>,
}Expand description
How a failing step is retried. Attempts include the first one.
A failure marked final (Failure::fatal, or retryable: false) is
never retried, whatever the policy says.
Fields§
§attempts: u32§initial: Duration§factor: f64§max: Duration§jitter: boolEach delay is drawn between half of it and all of it, so retries of many runs that failed together spread out. On by default. The delay taken is recorded, so a replay waits for the same time.
max_elapsed: Option<Duration>No retry starts later than this after the step’s first failure.
non_retryable: Vec<String>Failures of these types (or caused by them) are not retried.
retry_if: Option<RetryIf>Called for each failure that could be retried; false makes it final.
on_exhausted: Option<Exhausted>When retries run out; None takes the engine’s
(Config::on_exhausted, else fail).
Implementations§
§impl RetryPolicy
impl RetryPolicy
pub fn none() -> Self
pub fn none() -> Self
Run once; a failure is final.
pub fn exponential(attempts: u32, initial: Duration, max: Duration) -> Self
pub fn exponential(attempts: u32, initial: Duration, max: Duration) -> Self
attempts tries with exponential backoff from initial, capped at max.
pub fn no_jitter(self) -> Self
pub fn no_jitter(self) -> Self
Without jitter: each delay is exactly the backoff.
pub fn max_elapsed(self, limit: Duration) -> Self
pub fn max_elapsed(self, limit: Duration) -> Self
No retry starts later than limit after the first failure.
pub fn non_retryable(self, kind: impl Into<String>) -> Self
pub fn non_retryable(self, kind: impl Into<String>) -> Self
Failures of type kind (or caused by one) are final.
pub fn retry_if(
self,
f: impl Fn(&Failure, u32) -> bool + Send + Sync + 'static,
) -> Self
pub fn retry_if( self, f: impl Fn(&Failure, u32) -> bool + Send + Sync + 'static, ) -> Self
f(failure, attempt) decides whether each failure is retried.
pub fn on_exhausted(self, then: Exhausted) -> Self
pub fn on_exhausted(self, then: Exhausted) -> Self
What the step does when its retries run out (Exhausted::Pause:
the run waits for a resume).
pub fn allows(&self, failure: &Failure, attempt: u32) -> bool
pub fn allows(&self, failure: &Failure, attempt: u32) -> bool
Whether failure, from attempt attempt, may be retried.
pub fn retryable(&self, failure: &Failure, attempt: u32) -> bool
pub fn retryable(&self, failure: &Failure, attempt: u32) -> bool
Whether failure is one the policy retries at all (not final),
whatever attempts remain.
pub fn delay(&self, failed_attempt: u32) -> Duration
Trait Implementations§
§impl Clone for RetryPolicy
impl Clone for RetryPolicy
§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more