aide-de-camp-sqlite
A SQLite backed implementation of the job Queue.
NOTE: It is possible that a single job gets sent to two runners. This is due to SQLite lacking
row locking and BEGIN EXCLUSIVE TRANSACTION not working well (it was very slow) for this use
case. This is only an issue at high concurrency, in which case you probably don't want to use
SQLite in the first place. In other words, this isn't "Exactly Once" kind of queue.
Schema
(
jid TEXT PRIMARY KEY,
queue TEXT NOT NULL default 'default',
job_type TEXT not null,
payload blob not null,
retries int not null default 0,
scheduled_at INTEGER not null,
started_at INTEGER,
enqueued_at INTEGER not null default (strftime('%s', 'now'))
);
(
jid TEXT PRIMARY KEY,
queue TEXT NOT NULL,
job_type TEXT not null,
payload blob not null,
retries int not null,
scheduled_at INTEGER not null,
started_at INTEGER not null,
enqueued_at INTEGER not null,
died_at INTEGER not null default (strftime('%s', 'now'))
);
(
scheduled_at asc,
started_at asc,
queue,
job_type
);
Schema also included into this crate as SCHEMA_SQL constant in this crate.
Example
use ;
use ;
use async_trait;
use SqlitePool;
;
async