pub struct RetryPolicy<E> { /* private fields */ }Expand description
Policy for retry behavior.
This policy combines the interval function (backoff strategy), maximum attempts, and retry predicate (which errors to retry).
Implementations§
Source§impl<E> RetryPolicy<E>
impl<E> RetryPolicy<E>
Sourcepub fn new(max_attempts: usize, interval_fn: Arc<dyn IntervalFunction>) -> Self
pub fn new(max_attempts: usize, interval_fn: Arc<dyn IntervalFunction>) -> Self
Creates a new retry policy.
Sourcepub fn with_retry_predicate<F>(self, predicate: F) -> Self
pub fn with_retry_predicate<F>(self, predicate: F) -> Self
Sets a predicate to determine which errors should be retried.
Sourcepub fn should_retry(&self, error: &E) -> bool
pub fn should_retry(&self, error: &E) -> bool
Checks if the given error should be retried.
Sourcepub fn next_backoff(&self, attempt: usize) -> Duration
pub fn next_backoff(&self, attempt: usize) -> Duration
Computes the delay before the next retry attempt.
Auto Trait Implementations§
impl<E> Freeze for RetryPolicy<E>
impl<E> !RefUnwindSafe for RetryPolicy<E>
impl<E> Send for RetryPolicy<E>
impl<E> Sync for RetryPolicy<E>
impl<E> Unpin for RetryPolicy<E>
impl<E> UnsafeUnpin for RetryPolicy<E>
impl<E> !UnwindSafe for RetryPolicy<E>
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