Retry logic with exponential backoff for Hindsight operations.
Features:
- Configurable max retries and backoff timing
- Jitter to prevent thundering herd
- Retry classification (retry transient, fail fast on client errors)
Retry Classification
- Retry: connection_refused, timeout, 5xx errors
- No retry: 4xx errors, invalid response
Summary
Functions
Gets the delay for a specific retry attempt with jitter.
Determines if an error should be retried.
Wraps an operation with retry logic.
Types
Functions
@spec get_delay(non_neg_integer(), [pos_integer()]) :: pos_integer()
Gets the delay for a specific retry attempt with jitter.
Determines if an error should be retried.
@spec with_retry( (-> {:ok, term()} | {:error, term()}), keyword() ) :: retry_result()
Wraps an operation with retry logic.
Options
:max_retries- maximum retry attempts (default from config):backoff_ms- list of backoff delays in ms (default from config)
Example
Retry.with_retry(fn -> do_request() end, max_retries: 3)