#[non_exhaustive]
pub struct RetryConfig { pub max_attempts: RetryMaxAttempts, pub initial_delay_ms: RetryInitialDelayMs, pub delay_factor: RetryDelayFactor, pub max_delay_ms: RetryDelayMaxMs, pub max_stream_resume_attempts: RetryMaxStreamResumeAttempts, }
Expand description

Configures retries with exponential backoff

Overview

Retries can be done on the downloads themselves as well on the byte streams returned from a client. If an error occurs while streaming bytes ConDow will try to reconnect with retries and continue streaming where the previous stream failed. Streaming will always be aborted if no bytes were read 3 times in a row even though successful requests for a stream were made.

Retries can also be attempted on size requests.

Be aware that some clients might also do retries themselves based on their underlying implementation. In this case you should disable retries for either the client or ConDow itself.

Limitations

ConDow can only try to resume on byte stream errors if the underlying CondowClient returns an exact bound on the number of bytes returned when a new stream is created.

Fields (Non-exhaustive)

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
max_attempts: RetryMaxAttempts

The maximum number of retry attempts.

initial_delay_ms: RetryInitialDelayMs

The delay before the first retry attempt.

delay_factor: RetryDelayFactor

A factor to multiply a current delay with to get the next one

max_delay_ms: RetryDelayMaxMs

The maximum delay for a retry.

max_stream_resume_attempts: RetryMaxStreamResumeAttempts

The maximum number of attempts to resume a byte stream from the same offset.

Setting this to 0 will disable resumes. Enabling them has a small overhead since the current progress on a byte stream must be tracked.

Implementations

Tries to initialize all fields from environment variables prefixed with “CONDOW_” If no env variables were found None is returned. Otherwise thise found will be set and the rest will be initialized with their defaults.

Tries to initialize all fields from environment variables without any prefix If no env variables were found None is returned. Otherwise thise found will be set and the rest will be initialized with their defaults.

Tries to initialize all fields from environment variables prefixed with “[prefix]_”

The underscore is omitted if prefix is empty If no env variables were found None is returned. Otherwise thise found will be set and the rest will be initialized with their defaults.

Set the maximum number of attempts for retries

Set the delay for the first retry attempt after the original operation failed

Set the factor by which each current delay will be multiplied by to get the next delay

This is actually what makes it exponentially when greater than 1.0.

Set the maximum duration in milliseconds for a single delay

The maximum number of attempts to resume a byte stream from the same offset.

Setting this to 0 will disable resumes. Enabling them has a small overhead since the current progress on a byte stream must be tracked.

Disable attempts to resume a byte stream from the same offset.

Validate this RetryConfig

Succeeds if

  • delay_factor is at least 1.0
  • delay_factor is a number

Validate this RetryConfig and return it if it is valid.

Can be used as a finalizer after builder style construction.

See also RetryConfig::validate

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Returns the argument unchanged.

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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

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