evoq_retry_strategy (evoq v1.14.1)
View SourceRetry strategies for error handling.
Provides various backoff strategies: - immediate: No delay between retries - fixed: Constant delay - exponential: Doubles each time up to max - exponential_jitter: Exponential with random jitter
Usage
%% Get delay for attempt 3 with exponential backoff
Delay = evoq_retry_strategy:next_delay({exponential, 100, 30000}, 3).
%% Returns approximately 400ms (100 * 2^2)
Summary
Functions
Create an exponential backoff strategy.
Create an exponential backoff with jitter strategy.
Create a fixed delay retry strategy.
Create an immediate retry strategy.
Calculate the next delay for a given attempt.
Types
-type strategy() :: immediate | {fixed, DelayMs :: pos_integer()} | {exponential, BaseMs :: pos_integer(), MaxMs :: pos_integer()} | {exponential_jitter, BaseMs :: pos_integer(), MaxMs :: pos_integer()}.
Functions
-spec exponential(pos_integer(), pos_integer()) -> {exponential, pos_integer(), pos_integer()}.
Create an exponential backoff strategy.
-spec exponential_jitter(pos_integer(), pos_integer()) -> {exponential_jitter, pos_integer(), pos_integer()}.
Create an exponential backoff with jitter strategy.
-spec fixed(pos_integer()) -> {fixed, pos_integer()}.
Create a fixed delay retry strategy.
-spec immediate() -> immediate.
Create an immediate retry strategy.
-spec next_delay(strategy(), pos_integer()) -> pos_integer().
Calculate the next delay for a given attempt.