Queue
@warlock.js/queue runs background work outside the request/response
cycle — sending an invoice email, syncing inventory, generating a
report — as durable jobs stored in Redis via BullMQ.
A job survives a process restart, retries on failure with backoff, and
can be picked up by any worker process that shares the same Redis and
job definitions.
Redis is required. BullMQ has no other backend.
This is not the same as @warlock.js/core’s Queue class, which is
an in-memory batcher inside one process (nothing stored, no retries,
lost on exit). Reach for @warlock.js/queue whenever the work must
survive a restart or be retried.
Try it in fifteen lines
Section titled “Try it in fifteen lines”import { defineConfig } from "@warlock.js/core";import { defineJob, queueConnector } from "@warlock.js/queue";
export default defineConfig({ connectors: [queueConnector()],});
// anywhere in app codeexport const sendInvoice = defineJob({ name: "invoices.send", attempts: 5, backoff: { type: "exponential", delay: 2000 }, async handle(payload: { invoiceId: string }, ctx) { await ctx.progress(50); },});
await sendInvoice.dispatch({ invoiceId: "42" }, { delay: "10m", priority: 1 });The connector starts workers once your app code (and therefore every
defineJob) has loaded, and drains active jobs on shutdown.
Read by intent
Section titled “Read by intent”- First time using it → Getting started.
- Understanding the mental model → Essentials.
- Looking up “how do I…?” → Guides.
- Copy-paste a real task → Recipes.
- Method-by-method lookup → Reference.