pub enum RetryPolicy {
Infinite,
None,
FixedDelay {
interval: Option<Duration>,
max_attempts: Option<u32>,
max_duration: Option<Duration>,
on_max_attempts: OnMaxAttempts,
},
Exponential {
initial_interval: Duration,
factor: f32,
max_interval: Option<Duration>,
max_attempts: Option<u32>,
max_duration: Option<Duration>,
on_max_attempts: OnMaxAttempts,
},
}Expand description
This struct represents the policy to execute retries.
Variants§
Infinite
§Infinite
Infinite retry strategy.
None
§None
No retry strategy, fail on first failure.
FixedDelay
§Fixed delay
Retry with a fixed delay strategy.
Fields
interval: Option<Duration>§Interval
Interval between retries. If none, the runtime will provide one based on the invoker retry policy.
max_attempts: Option<u32>§Max attempts
Gives up retrying when either this number of attempts is reached,
or max_duration (if set) is reached first.
Infinite retries if this field and max_duration are unset.
max_duration: Option<Duration>§Max duration
Gives up retrying when either the retry loop lasted for this given max duration,
or max_attempts (if set) is reached first.
Infinite retries if this field and max_attempts are unset.
on_max_attempts: OnMaxAttempts§On max attempts
What to do once max_attempts or max_duration is reached.
Exponential
§Exponential
Retry with an exponential strategy. The next retry is computed as min(last_retry_interval * factor, max_interval).
Fields
factor: f32§Factor
The factor to use to compute the next retry attempt. This value should be higher than 1.0
max_attempts: Option<u32>§Max attempts
Gives up retrying when either this number of attempts is reached,
or max_duration (if set) is reached first.
Infinite retries if this field and max_duration are unset.
max_duration: Option<Duration>§Max duration
Gives up retrying when either the retry loop lasted for this given max duration,
or max_attempts (if set) is reached first.
Infinite retries if this field and max_attempts are unset.
on_max_attempts: OnMaxAttempts§On max attempts
What to do once max_attempts or max_duration is reached.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
pub fn fixed_delay( interval: Option<Duration>, max_attempts: Option<u32>, max_duration: Option<Duration>, on_max_attempts: OnMaxAttempts, ) -> Self
pub fn exponential( initial_interval: Duration, factor: f32, max_attempts: Option<u32>, max_interval: Option<Duration>, max_duration: Option<Duration>, on_max_attempts: OnMaxAttempts, ) -> Self
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
Source§fn default() -> RetryPolicy
fn default() -> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more