retry library

Classes

RetryingClient
An http Client that sends each request again after a network error, a 429, a 502/503/504 or a 12002, following docs/RETRIES.md. Only a GET/HEAD or a request with an Idempotency-Key is repeated, except a 429 (refused before it ran), and it is repeated byte for byte. After the last allowed attempt the last response (or error) is returned unchanged. A streamed or multipart request cannot be sent twice, so it is sent once without retries.
RetryOptions
Options of RetryingClient; the defaults follow docs/RETRIES.md.

Constants

idempotencyKeyInProgressCode → const int
Body code of IDEMPOTENCY_KEY_IN_PROGRESS: the same key is still being processed.

Functions

enableRetries(ApiClient apiClient, [RetryOptions options = const RetryOptions()]) → ApiClient
Retries failed requests of apiClient as described in docs/RETRIES.md, by wrapping its HTTP client in a RetryingClient. Returns apiClient.
newIdempotencyKey() → String
A fresh random UUID (version 4) for the Idempotency-Key of one purchase intent.
parseRetryAfter(String? value, {DateTime? now}) → Duration?
The wait a Retry-After header asks for (whole seconds or an HTTP date); null when absent, invalid or negative.

Typedefs

RetryCallback = void Function(int attempt, String reason, Duration delay)
Called before each wait. attempt is the 1-based number of the retry about to be made.
RetrySleep = Future<void> Function(Duration delay)
The wait between attempts; replace it in tests so they run in milliseconds.