Retry
Index¶
- retry::with_linear_backoff
- retry::until_success
- retry::until_deadline
- retry::with_exponential_backoff
retry::with_linear_backoff¶
Retry a command with linear backoff. Sleeps base_sleep * attempt seconds between retries. Dies via log::die if the command does not succeed within max_tries attempts.
Arguments¶
- $1 (max_tries): (positive integer)
- $2 (base_sleep_seconds): (positive integer; sleep grows linearly: base, base2, base3, ...)
- ... (command): and args to run (variadic, at least one)
Exit codes¶
- 0: if the command succeeds within max_tries attempts
retry::until_success¶
Retry a command indefinitely until it succeeds, with no sleep between attempts. Intended for interactive prompts (e.g. passphrase entry) where the user reacts immediately to failure and backoff would only add friction. No max-attempt cap — the caller's command must provide its own escape hatch (e.g. SIGINT) if the operation should not be retried forever.
Arguments¶
- ... (command): and args to run (variadic, at least one)
Exit codes¶
- 0: once the command succeeds
retry::until_deadline¶
Poll a command at a constant interval until it succeeds or a wall-clock deadline passes. Unlike the backoff variants (which cap by attempt count and grow the sleep), this caps by elapsed wall-clock time and keeps the sleep fixed at interval_seconds. Elapsed time is measured via the bash SECONDS builtin against a start offset captured at entry. Dies via log::die if the command does not succeed before timeout_seconds elapse.
Arguments¶
- $1 (timeout_seconds): (positive integer; wall-clock deadline)
- $2 (interval_seconds): (positive integer; constant sleep between attempts)
- ... (command): and args to run (variadic, at least one)
Exit codes¶
- 0: if the command succeeds before the deadline
retry::with_exponential_backoff¶
Retry a command with exponential backoff. Sleeps base_sleep * 2^(attempt-1) seconds between retries. Dies via log::die if the command does not succeed within max_tries attempts.
Arguments¶
- $1 (max_tries): (positive integer)
- $2 (base_sleep_seconds): (positive integer; sleep grows exponentially: base, base2, base4, ...)
- ... (command): and args to run (variadic, at least one)
Exit codes¶
- 0: if the command succeeds within max_tries attempts