pub(super) trait BackoffSchedule {
// Required methods
fn max_retries(&self) -> Option<usize>;
fn overall_timeout(&self) -> Option<Duration>;
fn single_attempt_timeout(&self) -> Option<Duration>;
fn next_delay<E: RetriableError>(&mut self, error: &E) -> Option<Duration>;
}
Expand description
A trait that specifies the parameters for retrying a fallible operation.
Required Methods§
Sourcefn max_retries(&self) -> Option<usize>
fn max_retries(&self) -> Option<usize>
The maximum number of retries.
A return value of None
indicates is no upper limit for the number of retries, and that
the operation should be retried until BackoffSchedule::overall_timeout
time elapses (or
indefinitely, if BackoffSchedule::overall_timeout
returns None
).
Sourcefn overall_timeout(&self) -> Option<Duration>
fn overall_timeout(&self) -> Option<Duration>
The total amount of time allowed for the retriable operation.
A return value of None
indicates the operation should be retried until
BackoffSchedule::max_retries
number of retries are exceeded (or indefinitely, if
BackoffSchedule::max_retries
returns None
).
Sourcefn single_attempt_timeout(&self) -> Option<Duration>
fn single_attempt_timeout(&self) -> Option<Duration>
The total amount of time allowed for a single operation.
Sourcefn next_delay<E: RetriableError>(&mut self, error: &E) -> Option<Duration>
fn next_delay<E: RetriableError>(&mut self, error: &E) -> Option<Duration>
Return the delay to introduce before the next retry.
The error
parameter contains the error returned by the fallible operation. This enables
implementors to (optionally) implement adaptive backoff. For example, if the operation is
sending an HTTP request, and the error is a 429 (Too Many Requests) HTTP response with a
Retry-After
header, the implementor can implement a backoff schedule where the next retry
is delayed by the value specified in the Retry-After
header.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.