Struct ore::retry::Retry [−][src]
pub struct Retry {
initial_backoff: Duration,
factor: f64,
clamp_backoff: Duration,
limit: RetryLimit,
}
network
only.Expand description
Configures a retry operation.
See the module documentation for usage examples.
Fields
initial_backoff: Duration
factor: f64
clamp_backoff: Duration
limit: RetryLimit
Implementations
Sets the initial backoff for the retry operation.
The initial backoff is the amount of time to wait if the first try fails.
Clamps the maximum backoff for the retry operation.
The maximum backoff is the maximum amount of time to wait between tries.
Sets the exponential backoff factor for the retry operation.
The time to wait is multiplied by this factor after each failed try. The default factor is two.
Sets the maximum number of tries.
If the operation is still failing after max_tries
, then
retry
will return the last error.
Maximum durations and maximum tries are mutually exclusive within a
given Retry
operation. Calls to max_tries
will override any
previous calls to max_tries
or max_duration
.
Panics
Panics if max_tries
is zero.
Sets the maximum duration.
If the operation is still failing after the specified duration
, then
the operation will be retried once more and retry
will
return the last error.
Maximum durations and maximum tries are mutually exclusive within a
given Retry
operation. Calls to max_duration
will override any
previous calls to max_duration
or max_tries
.
Retries the fallible operation f
according to the configured policy.
The retry
method invokes f
repeatedly until it succeeds or until the
maximum duration or tries have been reached, as configured via
max_duration
or
max_tries
. If f
never succeeds, then retry
returns f
’s return value from its last invocation.
After the first failure, retry
sleeps for the initial backoff
configured via initial_backoff
. After each
successive failure, retry
sleeps for twice the last backoff. If the
backoff would ever exceed the maximum backoff configured viq
Retry::clamp_backoff
, then the backoff is clamped to the specified
maximum.
The operation does not attempt to forcibly time out f
, even if there
is a maximum duration. If there is the possibility of f
blocking
forever, consider adding a timeout internally.
pub async fn retry_async<F, U, T, E>(self, f: F) -> Result<T, E> where
F: FnMut(RetryState) -> U,
U: Future<Output = Result<T, E>>,
pub async fn retry_async<F, U, T, E>(self, f: F) -> Result<T, E> where
F: FnMut(RetryState) -> U,
U: Future<Output = Result<T, E>>,
Like Retry::retry
but for asynchronous operations.
Convert into RetryStream
Trait Implementations
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more