View Source EventStreamex.Operators.Logger.ErrorLoggerAdapter behaviour (EventStreamex v1.3.1)
Behaviour to handle errors with operators (EventStreamex.Operators.Operator
).
When implementing this behaviour, you must put use a GenServer
.
There is currently one adapter available and used by default: EventStreamex.Operators.Logger.LoggerAdapter
.
This adapter simply logs the error to the console.
The executor (EventStreamex.Operators.Executor
) who catches the operator failure and
calls the error logger will also execute a telemetry event so that you can
see errors over time in a chart.
There are 2 kinds of errors:
- Retry: The operator failed but will retry soon
- Failed: The operator retried several times but failed again.
For more information about the retry strategy, see EventStreamex.Operators.Executor
.
Summary
Types
The retry status
Callbacks
Same as log_retry/3
but when no more retry will be attempted
Logs an error with the operator, that will be retried again soon.
This function will be called at startup to spawn the error logger adapter.
Functions
Returns a specification to start this module under a supervisor.
Types
@type retry_status() :: %{ max_retries: integer(), curr_retries: integer(), max_restart_time: integer(), backoff_multiplicator: float(), curr_time_to_wait: integer() }
The retry status:
max_retries
: Maximum number of retries attemptedcurr_retries
: The current retries count already attempted (starting at 1 after the first failure)max_restart_time
: The maximum number of milliseconds to wait for the next retrybackoff_multiplicator
: A decimal number multiplied to thecurr_time_to_wait
to define the next amount of time to wait for the next retry (maxed bymax_restart_time
)curr_time_to_wait
: The current time to wait in milliseconds before the next retry
Callbacks
@callback log_failed(atom(), any(), retry_status()) :: :ok
Same as log_retry/3
but when no more retry will be attempted
Params
module
: The module of the operatorreason
: The failure reasonretry_status
: The current retry count, the time to wait for the next retry, etc...
@callback log_retry(atom(), any(), retry_status()) :: :ok
Logs an error with the operator, that will be retried again soon.
Params
module
: The module of the operatorreason
: The failure reasonretry_status
: The current retry count, the time to wait for the next retry, etc...
This function will be called at startup to spawn the error logger adapter.
The param comes from the configuration of the adapter:
error_logger_adapter: {EventStreamex.Operators.Logger.LoggerAdapter, []},
The return value is a tuple with the pid of the spawned process
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.