Resource System
Inject external dependencies into tasks and intercept jobs before they enqueue.
Inject external dependencies into tasks and intercept jobs before they enqueue.
Task arguments cross a process boundary, so they must be serializable — but most real dependencies (database pools, HTTP clients, cloud SDKs) are not. The Node SDK keeps those on the worker and passes only plain data through the queue.
import { Queue, useResource } from "@byteveda/flexiq";
import { Pool } from "pg";
const queue = new Queue({ dbPath: "tasks.db" });
queue.resource("db", () => new Pool(), { dispose: (p) => p.end() });
queue.task("sync", async (id: string) => {
const db = await useResource<Pool>("db");
await db.query("UPDATE users SET synced = now() WHERE id = $1", [id]);
});Coming from Python? Node's resource system is intentionally lighter — enqueue
interception is a single onEnqueue hook rather than a set of strategies,
and resources are registered in code with no TOML loader. Scopes, pooling,
health checks, hot reload, and signed proxies all have direct equivalents.