pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: f64,
pub max_delay: f64,
pub multiplier: f64,
pub jitter: f64,
pub retry_on: Option<Arc<dyn Fn(&(dyn Error + 'static)) -> bool + Send + Sync>>,
}Expand description
How to retry factory.create(): exponential backoff with jitter.
jitter in [0, 1]: 0 = deterministic delays, 1 = “full jitter” (uniform in
[0, delay]). retry_on narrows what is retryable (e.g. don’t retry auth failures);
None means retry everything.
Fields§
§max_attempts: u32Maximum attempts (including the first). 1 = no retries.
base_delay: f64Base delay in seconds for the first retry.
max_delay: f64Upper bound on any single delay, in seconds.
multiplier: f64Exponential growth factor between attempts.
jitter: f64Jitter fraction in [0, 1].
retry_on: Option<Arc<dyn Fn(&(dyn Error + 'static)) -> bool + Send + Sync>>Optional predicate: retry only when it returns true. None = retry everything.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn with_retry_on<F>(self, predicate: F) -> Self
pub fn with_retry_on<F>(self, predicate: F) -> Self
Returns a copy with retry_on set to predicate.
Sourcepub fn should_retry(&self, err: &(dyn Error + 'static)) -> bool
pub fn should_retry(&self, err: &(dyn Error + 'static)) -> bool
Reports whether err is retryable under this policy.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl !RefUnwindSafe for RetryPolicy
impl !UnwindSafe for RetryPolicy
impl Freeze for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
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