Roger.Partition.Worker (roger v4.0.1)

Copy Markdown View Source

Handles the decoding and execution of a single job.

Besides running the job, various administrative tasks need to be performed as well, namely:

  • Check whether the job has not been cancelled in the meantime

  • Check whether another job is currently running with the same execution_key, and if so, delay this current job until the currently running one finishes

  • On job failure, the job needs to be queued in the retry queue, if the job is marked retryable. By default, jobs are not retried.

Summary

Functions

Returns a specification to start this module under a supervisor.

This function starts processing the job as soon as the worker GenServer is started up.

Callback implementation for GenServer.init/1.

This will make sure the worker task is killed when the worker get's stopped

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle_info(msg, state)

@spec handle_info(:timeout, Roger.Partition.Worker.State.t()) ::
  {:noreply, Roger.Partition.Worker.State.t()}
  | {:stop, :normal, Roger.Partition.Worker.State.t()}
@spec handle_info(:job_finished, Roger.Partition.Worker.State.t()) ::
  {:stop, :normal, Roger.Partition.Worker.State.t()}
@spec handle_info(:job_errored, Roger.Partition.Worker.State.t()) ::
  {:stop, :normal, Roger.Partition.Worker.State.t()}
@spec handle_info(:handle_job_timeout, Roger.Partition.Worker.State.t()) ::
  {:stop, :normal, Roger.Partition.Worker.State.t()}
@spec handle_info(
  {:DOWN, reference(), :process, pid(), String.t()},
  Roger.Partition.Worker.State.t()
) ::
  {:stop, :normal, Roger.Partition.Worker.State.t()}

This function starts processing the job as soon as the worker GenServer is started up.

init(list)

Callback implementation for GenServer.init/1.

name(job_id)

start_link(worker_input)

terminate(reason, state)

@spec terminate(any(), Roger.Partition.Worker.State.t()) :: any()

This will make sure the worker task is killed when the worker get's stopped