Implements exponential backoff with jitter for retrying failed API calls
with_retry(
expr,
max_retries = 3,
base_delay = 1,
max_delay = 60,
backoff_factor = 2,
jitter = TRUE,
retry_on = function(e) is_transient_error(e),
on_retry = NULL
)Result of successful expression evaluation
Expression to evaluate (usually an API call)
Maximum number of retry attempts
Base delay in seconds for first retry
Maximum delay in seconds
Multiplier for delay between retries
Whether to add random jitter to prevent thundering herd
Function that takes an error and returns TRUE if should retry
Function called on each retry attempt with attempt number and error