pub struct RetryWithBackoffPolicy<P> {
pub inner: P,
pub max_retries: u32,
pub backoff_base_ms: u64,
pub backoff_cap_ms: Option<u64>,
pub jitter_ratio: f64,
}Expand description
Policy that returns RetryAfterMs with exponential backoff (and optional jitter) for the first max_retries attempts, then Fail. For RateLimited errors with retry_after_ms, uses that value when set.
Fields§
§inner: P§max_retries: u32§backoff_base_ms: u64Base delay in ms; actual delay = min(cap, backoff_base_ms * 2^attempt) + jitter.
backoff_cap_ms: Option<u64>Max delay cap in ms (optional).
jitter_ratio: f64Jitter ratio in [0.0, 1.0]; added randomness to avoid thundering herd.
Implementations§
Trait Implementations§
Source§impl<P: Policy> Policy for RetryWithBackoffPolicy<P>
impl<P: Policy> Policy for RetryWithBackoffPolicy<P>
Whether the action is allowed for this run and context.
Source§fn retry_strategy_attempt(
&self,
err: &ActionError,
action: &Action,
attempt: u32,
) -> RetryDecision
fn retry_strategy_attempt( &self, err: &ActionError, action: &Action, attempt: u32, ) -> RetryDecision
Retry strategy with attempt count and structured error. Default uses kind: Permanent => Fail,
others may be retried by implementations. Applies only to executor
Err; ActionResult::Failure is not retried. Read moreSource§fn budget(&self) -> BudgetRules
fn budget(&self) -> BudgetRules
Optional budget; default is no limits.
Source§fn retry_strategy(&self, err: &dyn Display, _action: &Action) -> RetryDecision
fn retry_strategy(&self, err: &dyn Display, _action: &Action) -> RetryDecision
Whether to retry after an error (and optionally after a delay).
Auto Trait Implementations§
impl<P> Freeze for RetryWithBackoffPolicy<P>where
P: Freeze,
impl<P> RefUnwindSafe for RetryWithBackoffPolicy<P>where
P: RefUnwindSafe,
impl<P> Send for RetryWithBackoffPolicy<P>where
P: Send,
impl<P> Sync for RetryWithBackoffPolicy<P>where
P: Sync,
impl<P> Unpin for RetryWithBackoffPolicy<P>where
P: Unpin,
impl<P> UnsafeUnpin for RetryWithBackoffPolicy<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for RetryWithBackoffPolicy<P>where
P: UnwindSafe,
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