pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
}Expand description
Retry policy: max_attempts tries in total, delay of attempt n (from 0)
uniformly in [d/2, d] with d = min(base * 2^n, max_delay) (“equal
jitter”), or the server’s Retry-After when longer (capped at max_delay).
Fields§
§max_attempts: u32Total attempts including the first one.
base_delay: DurationBase delay.
max_delay: DurationUpper bound of one delay.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn delay(
&self,
attempt: u32,
retry_after: Option<Duration>,
rng: &JitterRng,
) -> Duration
pub fn delay( &self, attempt: u32, retry_after: Option<Duration>, rng: &JitterRng, ) -> Duration
Delay before retry number attempt (0 = first retry).
Sourcepub async fn run<T, F, Fut>(
&self,
rng: &JitterRng,
operation: F,
) -> Result<T, ProviderError>
pub async fn run<T, F, Fut>( &self, rng: &JitterRng, operation: F, ) -> Result<T, ProviderError>
Runs operation until it succeeds, fails with a non-retryable kind, or
attempts run out. Returns the last error.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
impl Copy for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
impl Eq for RetryPolicy
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
impl StructuralPartialEq for RetryPolicy
Auto Trait Implementations§
impl Forget for RetryPolicy
impl Freeze for RetryPolicy
impl Move 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.