A piece of Storehouse's work done out of the request: a file's
analysis, a deletion, a mirror's copy. A runner keeps it and runs it
(Storehouse.Runner).
A job is a worker, a module of this behaviour, and its arguments, a map
JSON holds, so that any runner can keep it: in memory, in a database
(Oban), in a workflow engine. to_map/1 gives a job as JSON holds it,
and from_map/1 gives it back.
A runner calls run/1 until it gives :ok, at most :max_attempts
times, then discarded/3.
Telemetry
Each run is a span, [:storehouse, :job, :start | :stop | :exception],
with the job's :worker and :unique, and result: :ok | :error;
a job given up is [:storehouse, :job, :discarded], with
%{attempts: n} and the :job and the :reason.
Summary
Callbacks
Does the job's work, with its arguments: :ok, or why it failed, to be tried again.
Functions
Tells that a runner gave the job up after attempts: a warning in the
log, and the event [:storehouse, :job, :discarded].
The job of a map to_map/1 gave, or {:error, {:not_a_worker, name}}
when its worker is not a module of this behaviour, in this app.
A job of worker with args, a map with string keys that JSON holds.
Runs the job once: :ok, or {:error, reason} for a runner to try it
again. A worker that raises gives its message as the reason.
The job as JSON holds it, for a runner that keeps it out of memory.
Types
@type t() :: %Storehouse.Job{ args: map(), max_attempts: pos_integer(), unique: String.t(), worker: module() }
Callbacks
Functions
@spec discarded(t(), term(), pos_integer()) :: :ok
Tells that a runner gave the job up after attempts: a warning in the
log, and the event [:storehouse, :job, :discarded].
The job of a map to_map/1 gave, or {:error, {:not_a_worker, name}}
when its worker is not a module of this behaviour, in this app.
A job of worker with args, a map with string keys that JSON holds.
:unique- what makes two jobs one while one waits (a runner that can keeps one of them). The default is the worker and its arguments.:max_attempts- how many times it is tried. The default is 10.
Runs the job once: :ok, or {:error, reason} for a runner to try it
again. A worker that raises gives its message as the reason.
The job as JSON holds it, for a runner that keeps it out of memory.