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

Link to this type

retry_status()

View Source (since 1.0.0)
@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 attempted
  • curr_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 retry
  • backoff_multiplicator: A decimal number multiplied to the curr_time_to_wait to define the next amount of time to wait for the next retry (maxed by max_restart_time)
  • curr_time_to_wait: The current time to wait in milliseconds before the next retry

Callbacks

Link to this callback

log_failed(atom, any, retry_status)

View Source (since 1.0.0)
@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 operator
  • reason: The failure reason
  • retry_status: The current retry count, the time to wait for the next retry, etc...
Link to this callback

log_retry(atom, any, retry_status)

View Source (since 1.0.0)
@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 operator
  • reason: The failure reason
  • retry_status: The current retry count, the time to wait for the next retry, etc...
Link to this callback

start_link(any)

View Source (since 1.0.0)
@callback start_link(any()) :: {:ok, pid()}

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

Link to this function

child_spec(init_arg)

View Source (since 1.0.0)

Returns a specification to start this module under a supervisor.

See Supervisor.