API Reference

See also: Configuration for env vars and config-file options.

new Queue(options)

Creates a new queue instance.

optiontypedefault
namestringrequired
connectionstringsqlite local file
retriesnumber3
backoff"fixed" | "exponential""exponential"

queue.enqueue(data, opts?)

Adds a job to the queue. Returns a job id (string). Optional opts.delay (ms) and opts.priority (number, higher runs first).

queue.process(handler)

Registers a handler that consumes jobs. The handler receives a job object with id, data, and attempts.

queue.schedule(cron, data)

Enqueues a job on a recurring cron schedule, e.g. queue.schedule("0 * * * *", { task: "cleanup" }).