Struct ore::retry::Retry[][src]

pub struct Retry {
    initial_backoff: Duration,
    factor: f64,
    clamp_backoff: Duration,
    limit: RetryLimit,
}
This is supported on crate feature network only.
Expand description

Configures a retry operation.

See the module documentation for usage examples.

Fields

initial_backoff: Durationfactor: f64clamp_backoff: Durationlimit: 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.

Like Retry::retry but for asynchronous operations.

Convert into RetryStream

Trait Implementations

Formats the value using the given formatter. Read more

Constructs a retry operation with defaults that are reasonable for a fallible network operation.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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