Skip to main content

Module database

Module database 

Source
Expand description

The database driver: a jobs table, a failed_jobs table, and a reservation that is safe when several workers race for the same row.

Timestamps are stored as epoch seconds in bigint columns rather than as timestamptz. rustlavel-db deliberately leaves a timestamp column as text so precision survives, and a queue compares times far more often than it shows them: an integer sorts, compares and indexes without anything having to agree on a text format.

Structs§

CreateJobProgressTable
CreateQueueTables
DatabaseProgress
Progress in a table. The one to use once the worker is its own process.
DatabaseQueue
A queue backed by two database tables.

Constants§

FAILED_JOBS_TABLE
JOBS_TABLE
The conventional table names, matching Laravel’s.
JOB_PROGRESS_TABLE

Functions§

create_tables
Create the queue’s two tables.
define_failed_jobs_table
The dead-letter table.
define_job_progress_table
Where a job’s progress is kept, so a worker in one process and a request handler in another read the same row.
define_jobs_table
The jobs table. A free function rather than a closure so a test can build the statements without a database, and see the same schema production gets.