Vug::RetryHelpers
Shared retry and backoff utilities for transient failure handling.
Class methods
Calculate exponential backoff delay with jitter. Used for retrying transient failures (timeouts, socket errors, etc.)
- attempt: current attempt number (0-indexed)
- base_delay: initial delay before first retry
- max_delay: maximum delay cap Returns: delay duration with 0-25% random jitter added
with_retry(max_retries : Int32, base_delay : Time::Span, max_delay : Time::Span, retryable : Proc(Exception, Bool) | Nil = nil, on_retry : Proc(Int32, Exception, Time::Span, Nil) | Nil = nil, & : -> T) forall T
Execute a block with retry logic for transient failures.
- max_retries: maximum number of retry attempts
- base_delay: initial delay between retries
- max_delay: maximum delay cap
- retryable: proc to determine if an exception is retryable
- on_retry: optional callback called before each retry (for logging)
- &block: the operation to execute
Returns the block's result on success, or raises the last exception.