evoq_failure_context (evoq v1.14.1)
View SourceFailure context for tracking retry state.
Maintains state across retry attempts for event handlers. Used to implement sophisticated retry strategies with exponential backoff, jitter, and dead letter handling.
Summary
Functions
Get the current attempt number.
Get the duration since first failure.
Get the error that caused the failure.
Get the event that failed.
Get the handler module.
Increment the attempt counter and update timestamp.
Create a new failure context.
Add stacktrace to the context.
Functions
-spec get_attempt(#evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> pos_integer().
Get the current attempt number.
-spec get_duration(#evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> non_neg_integer().
Get the duration since first failure.
-spec get_error(#evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> term().
Get the error that caused the failure.
-spec get_event(#evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> map().
Get the event that failed.
-spec get_handler(#evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> atom().
Get the handler module.
-spec increment(#evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> #evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}.
Increment the attempt counter and update timestamp.
-spec new(atom(), map(), term()) -> #evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}.
Create a new failure context.
-spec with_stacktrace(list(), #evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}) -> #evoq_failure_context{handler_module :: atom(), event :: map(), error :: term(), attempt_number :: pos_integer(), first_failure_at :: integer(), last_failure_at :: integer(), stacktrace :: list()}.
Add stacktrace to the context.