Skip to main content

Crate larust_queue

Crate larust_queue 

Source
Expand description

A durable job queue - Laravel’s dispatch(new Job)/queue:work. Unlike larust-events (in-process, synchronous, no persistence), a Job survives the current request and even a process restart: dispatch() enqueues it durably; a separate xr queue:work process (backed by work()) claims and executes jobs until stopped.

Backed by SQL-family storage (Config::queue_driver == "database", the default) or Redis ("redis") - see dispatch/[worker]’s own doc comments for the dispatch shape, and [sql_worker]/[redis_worker] for the two claim/lease/retry implementations.

Structs§

JobRegistry
Maps a Job::JOB_TYPE tag back to the concrete type that can deserialize and run it - built fresh by whatever calls work() (typically the generated app’s own queue:work branch in main.rs), not a process-wide static: only one work() loop reads it, in the one process running it, so there’s no cross-request sharing need the way larust-events’ listener registry or larust_http::route’s named-route registry have.

Traits§

Job
A unit of deferred work. Implemented once per job type, the same “app implements this once per thing” shape as Policy<U>/Mailable.

Functions§

dispatch
Serializes job to JSON and enqueues it - durable the moment this returns Ok, independent of whether any xr queue:work process is currently running to pick it up.
work
Runs forever, claiming and executing jobs one at a time until the process is stopped (Ctrl+C / killed - no signal handling here, same as Laravel’s own queue:work without --stop-when-empty). A job whose handler fails, or whose job_type has no registered handler, is recorded as a failure rather than retried forever or silently dropped.