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

Link to this function

enqueue(module, payload, opts)

View Source
enqueue(atom(), any(), Keyword.t()) :: :ok | {:error, String.t()}

Queue a job to be performed by this module's perform/1 function later.

Intended for use through modules that use Jorb.Job.

Link to this function

work(module, opts)

View Source
work(atom(), Keyword.t()) :: :ok | {:error, String.t()}

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.

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

Link to this callback

perform(any)

View Source
perform(any()) :: :ok | :error

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.

Link to this callback

read_queues()

View Source
read_queues() :: [Jorb.queue()]

List of queues to fetch jobs from, given in highest-priority-first order.

Link to this callback

write_queue()

View Source (optional)
write_queue() :: Jorb.queue()

Queue to write to. Implement this or write_queue/1.

Link to this callback

write_queue(any)

View Source (optional)
write_queue(any()) :: Jorb.queue()

Queue to write to, for the given payload. Implement this or write_queue/0.