roger v1.0.0 Roger.Partition.Worker.Callback behaviour
Provides hooks into the job execution lifecycle.
Roger can be configured with callback modules for the job worker, which invokes functions on various places in the job’s life cycle.
config :roger, Roger.Partition.Worker,
callbacks: MyWorkerModule
In this scenario, the mentioned MyWorkerModule
needs to use
Roger.Worker.Callback
:
defmodule MyWorkerModule do
use Roger.Worker.Callback
end
In this worker module, you can implement the functions before_run/2
,
after_run/2
, on_error/4
, on_cancel/2
and on_buried/2
to
respond to job events.
Summary
Callbacks
Executed just after the job has ran
Executed just before the job is going to run
Executed when the job has failed its retry sequence
Executed when the job was cancelled
Executed when a job has exited with an error
Callbacks
Executed just after the job has ran
Executed just before the job is going to run
on_buried(partition_id :: String.t, job :: Roger.Job.t, any, any) :: any
Executed when the job has failed its retry sequence
Retryable jobs are retried in an exponential fashion. When the job has failed the retry sequence, e.g. it failed every time, it is put in a special queue called “buried”. Upon placement in this queue, this callback gets executed.
Executed when the job was cancelled
A job can be cancelled either when it is still in the queue or while it is executing. The cancel callback will be only executed once.
Executed when a job has exited with an error