esdb_gater_retry (reckon_gater v1.1.2)

View Source

Retry logic with exponential backoff for reckon-gater

Provides configurable retry behavior with: - Exponential backoff with jitter - Maximum delay cap - Maximum retry count - Telemetry integration

Summary

Functions

Calculate delay for a given attempt (useful for testing)

Get default retry configuration from application environment

Execute a function with default retry configuration

Execute a function with custom retry configuration

Types

retry_config/0

-type retry_config() ::
          #retry_config{base_delay_ms :: pos_integer(),
                        max_delay_ms :: pos_integer(),
                        max_retries :: non_neg_integer()}.

retry_result/0

-type retry_result() :: {ok, term()} | {error, term()}.

Functions

calculate_delay(Attempt, Retry_config)

-spec calculate_delay(non_neg_integer(), retry_config()) -> non_neg_integer().

Calculate delay for a given attempt (useful for testing)

default_config()

-spec default_config() -> retry_config().

Get default retry configuration from application environment

with_retry(StoreId, Fun)

-spec with_retry(atom(), fun(() -> retry_result())) -> retry_result().

Execute a function with default retry configuration

with_retry(StoreId, Fun, Config)

-spec with_retry(atom(), fun(() -> retry_result()), retry_config()) -> retry_result().

Execute a function with custom retry configuration