rally_runtime/jobs
Durable background job runner backed by SQLite.
Jobs are rows in the system DB’s jobs table. A poller actor claims
ready jobs with UPDATE…RETURNING, runs the handler, and marks them
completed or schedules a retry. Failed jobs get quadratic backoff
(5s, 20s, 45s, 80s) and are dead-lettered after max_attempts.
Running jobs have a claimed_at lease so they can be reclaimed if the
process crashes. Use run_once for deterministic testing without the
polling actor.
Types
pub type Job {
Job(id: Int, name: String, payload: BitArray, attempts: Int)
}
Constructors
-
Job(id: Int, name: String, payload: BitArray, attempts: Int)
pub type JobHandler =
fn(String, BitArray) -> Result(Nil, String)
Values
pub fn enqueue(
db db: sqlight.Connection,
name name: String,
payload payload: BitArray,
run_at run_at: Int,
) -> Nil
pub fn enqueue_in(
db db: sqlight.Connection,
name name: String,
payload payload: BitArray,
delay_seconds delay_seconds: Int,
) -> Nil
pub fn run_once(
db db: sqlight.Connection,
handler handler: fn(String, BitArray) -> Result(Nil, String),
) -> Nil
pub fn run_once_at(
db db: sqlight.Connection,
now now: Int,
handler handler: fn(String, BitArray) -> Result(Nil, String),
) -> Nil
pub fn start_runner(
db db: sqlight.Connection,
handler handler: fn(String, BitArray) -> Result(Nil, String),
) -> Result(actor.Started(Nil), actor.StartError)