Queue
Construct a queue and the full producer/admin API.
Construct a queue and the full producer/admin API.
The Queue API is split across several pages for readability:
import { Queue } from "@byteveda/flexiq";
const queue = new Queue(options);| Option | Type | Description |
|---|---|---|
dbPath | string | SQLite file path (default backend). |
backend | "sqlite" | "postgres" | "redis" | Storage backend. |
dsn | string | Connection string for postgres/redis. |
poolSize | number | Connection pool size (sqlite/postgres). |
schema | string | Postgres schema (default flexiq). |
prefix | string | Redis key prefix. |
namespace | string | Namespace applied to enqueued jobs + the worker scheduler. |
serializer | Serializer | Arg/result serializer (default JsonSerializer). |
codec | PayloadCodec | PayloadCodec[] | Global codec chain wrapping the serializer — covers every payload and result. See Serializers. |
codecs | Record<string, PayloadCodec> | Named codec registry for per-task codecs (payload only). |
The constructor opens (and creates, if needed) the storage backend
synchronously — the declared entry point is the static JsQueue.open(options),
reached through the type rather than an instance, since there is no queue to
call it on yet. Anything that fails about the connection fails here, not at the
first enqueue.
| Method | Description |
|---|---|
task(name, fn, config?) | Register a task. See Task. |
discover(dir?, options?) | async. Import every task module under dir (default "tasks") and register the tasks they declare with the queue-less task(). Returns the sorted names now registered. See Task discovery. |
configureQueue(name, config) | Set per-queue rate limit / concurrency. |
enqueue(task, args?, options?) | Enqueue a job → job id. Throws if a gate rejects or skips. |
tryEnqueue(task, args?, options?) | Enqueue a job → job id, or null when a gate skipped it. A gate that rejects still throws. |
enqueueMany(task, jobs[]) | Batch-enqueue { args?, options? }[] → job ids in input order, uniqueKey entries deduped. |
workflows — Workflow builder + queries, exposed as queue.workflows.