Skip to main content

Module queue

Module queue 

Source
Expand description

The queue work waits in until it is done: a backend the application picks.

Ojak runs the loops — claiming, retrying, giving up — and keeps nothing between runs itself. What is queued lives in a Queue, so that it survives a restart. As in Fedify, the queue is pluggable: ojak-postgres keeps it in a table of its own, MemoryQueue keeps it in memory for tests and for servers that can afford to lose it, and an application with tables for the purpose already implements the trait over them.

Unlike Fedify’s, a queue here is claimed from rather than listened to. A worker claims jobs for a lease and then reports each one done, to be retried after a delay, or failed. A lease is what lets any number of workers in any number of processes share one queue: the two colours of a blue/green deploy both run one, and what a colour was holding when it stopped is handed out again when the lease lapses, not lost.

Structs§

Job
A job, claimed for processing.
MemoryQueue
A Queue in memory.
MemoryRecord
A job’s state in a MemoryQueue, for tests to inspect.
QueueError
A failure in the queue backend itself.
RetryPolicy
When to try a failed job again: how many attempts a job gets, and how long to wait after each failure.

Enums§

Backoff
How long to wait before trying a failed job again.

Traits§

DynQueue
A Queue behind a pointer, for where the backend is chosen at run time: an application with a database per tenant hands Ojak a different queue for each request. Any Queue is one; shared makes a SharedQueue.
Queue
A queue backend.

Functions§

shared
queue as a SharedQueue.

Type Aliases§

SharedQueue
A queue shared behind a pointer; see DynQueue.