Jorb v0.4.1 Jorb.Job behaviour View Source
Modules that use Jorb.Job
can enqueue, read, and perform jobs.
These modules must implement the Jorb.Job
behaviour.
In addition to the callbacks defined in Jorb.Job
, these modules also
export the enqueue/2
, work/1
, and workers/1
functions. See the
documention below for enqueue/3
, work/2
, and workers/2
.
See Jorb
for more documentation.
Link to this section Summary
Functions
Queue a job to be performed by this module's perform/1
function
later.
Attempt to fetch jobs to do, reading from the first item in
read_queues/0
that has messages. For each message received,
perform/1
is invoked, deleting the message if the return value
is :ok
.
Returns a list of child specs for GenServers that read (
execute work(opts)
forever) and write (flush batches of outgoing
messages).
Callbacks
Performs the given work. Behind the scenes, the message from which the
work originated will be deleted from the queue if this function returns
:ok
.
List of queues to fetch jobs from, given in highest-priority-first order.
Queue to write to.
Implement this or write_queue/1
.
Queue to write to, for the given payload.
Implement this or write_queue/0
.
Link to this section Functions
Queue a job to be performed by this module's perform/1
function
later.
Intended for use through modules that use Jorb.Job
.
Attempt to fetch jobs to do, reading from the first item in
read_queues/0
that has messages. For each message received,
perform/1
is invoked, deleting the message if the return value
is :ok
.
Intended for use through modules that use Jorb.Job
.
workers(module, opts)
View Sourceworkers(atom(), Keyword.t()) :: [:supervisor.child_spec()]
Returns a list of child specs for GenServers that read (
execute work(opts)
forever) and write (flush batches of outgoing
messages).
Intended for use through modules that use Jorb.Job
.
Link to this section Callbacks
Performs the given work. Behind the scenes, the message from which the
work originated will be deleted from the queue if this function returns
:ok
.
List of queues to fetch jobs from, given in highest-priority-first order.
Queue to write to.
Implement this or write_queue/1
.
Queue to write to, for the given payload.
Implement this or write_queue/0
.