pub struct RetryPolicy {
pub max_attempts: u32,
pub backoff_ms: u64,
pub strategy: BackoffStrategy,
}Fields§
§max_attempts: u32§backoff_ms: u64§strategy: BackoffStrategyImplementations§
Source§impl RetryPolicy
impl RetryPolicy
pub fn new( max_attempts: u32, backoff_ms: u64, strategy: BackoffStrategy, ) -> Self
Sourcepub async fn execute<F, Fut, T, E>(
&self,
f: F,
timeout: Duration,
) -> Result<T, RetryError<E>>
pub async fn execute<F, Fut, T, E>( &self, f: F, timeout: Duration, ) -> Result<T, RetryError<E>>
Run f up to max_attempts times, each under timeout.
- The first
Okis returned immediately. Erris retained as the last error and retried.- A timeout is recorded and retried (no error value is produced by a timeout).
If attempts are exhausted with a captured handler error, that error is
returned as RetryError::Exhausted. If they are exhausted with only
timeouts (or max_attempts == 0), RetryError::TimedOut is returned.
This method never panics.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe 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