@frank/jobs (0.1.0)
Installation
@frank:registry=npm install @frank/jobs@0.1.0"@frank/jobs": "0.1.0"About this package
@frank/jobs
Durable Postgres job queue for Frank products: enqueue, a leased worker loop,
SQL for job_queue (runner lanes, dedupe, product-owned priority), and a
transactional outbox. Ported unchanged in behaviour from Blockwise
worker/index.ts, src/lib/providers/job-queue-enqueue.ts,
worker/crm-provision-host.ts and the four job_queue migrations.
Public API
enqueueQueuedJob(service, input)/cancelQueuedJob(service, input)createWorker(service, config)->{ runOnce, reap, start, shutdown }hostLaneConfig({ kind, handler })-> single-kind host-lane configresolveWorkerConfig(config),configFromEnv(),BLOCKWISE_JOB_KIND_PRIORITYpriorityFunctionSql(kinds)/priorityCaseSql(kinds)/rankForKind(kinds, k)createCompensationFetch(transport, fetchImpl)LeaseLostError,WorkerRestartRequiredError, and the types
Config
The caller builds { kindPriority, handlers }. kindPriority is the product's
job kinds, highest first; the claim SQL honours it via queue_job_priority.
configFromEnv() reads the Blockwise WORKER_* names. No env reads elsewhere.
SQL (packages/jobs/sql)
001_job_queue.sql, 002_job_queue_rpcs.sql, then install your priority with
priorityFunctionSql() and rebuild job_queue_priority_claim_idx.
003_outbox.sql is the generic transactional outbox.
Example
const worker = createWorker(service, {
kindPriority: ["publish.meta.execute", "reporting.refresh"],
handlers: { "publish.meta.execute": myHandler },
});
await worker.start();
Dependencies
Development dependencies
| ID | Version |
|---|---|
| @types/node | ^22.20.4 |