14 Job Queues🔗
This module provides functionality for declaring and executing
asynchronous jobs. The job queuing functionality is implemented on
top of PostgreSQL so you don’t need an external message queue. Jobs
are guaranteed to be executed at least once after being enqueued.
14.1 Jobs🔗
A parameter that controls whether or not jobs should be executed
synchronously when applied. This comes in handy when you want to
test jobs at the REPL.
Returns #t when v is a job.
|
|
args | | = | | arg-id ... | | | | | | arg-id ... . rest-id | | | | | | option | | = | | #:queue queue-name | | | | | | #:priority priority |
|
|
|
Binds a function to id that enqueues an asynchronous job
when applied. The arguments passed to each job must be
prop:serializable. When the job is picked up by a worker,
its arguments are deserialized and its body is executed.
The queue-name option controls which queue the jobs are
enqueued to. If not supplied, it defaults to "default".
The priority option controls what the priority of each job
is within the queue. Zero is the highest priority. If not
supplied, this option defaults to 50.
When a job is executed synchronously, its result is always
#f, otherwise its result is the id of the job in the
koyo_jobs table.
Immediately terminates the current job and re-enqueues it so that it
may be executed again at a later time. Using this form outside the
body of a
define-job form is a syntax error.
Wraps job-expr so that it will be executed some time after
the timestamp represented by when-expr.
14.2 Brokers🔗
Job brokers handle the details of storing and retrieving
jobs to and from the database. Each broker permanently leases a
connection from the database pool to listen for notifications and then
other connections are leased and put back into the pool as needed.
Holds the current broker that is used to enqueue jobs.
Creates a broker component that enqueues its jobs in db.
The db parameter must refer to a PostgreSQL database.
14.3 Workers🔗
Job workers dequeue and execute jobs.
Generates a function that, when supplied a
job broker,
produces a
job worker that dequeues and executes jobs
published on the queue identified by
queue.