@frank/jobs (0.1.0)

Published 2026-09-26 16:35:31 +10:00 by steve

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 config
  • resolveWorkerConfig(config), configFromEnv(), BLOCKWISE_JOB_KIND_PRIORITY
  • priorityFunctionSql(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
Details
npm
2026-09-26 16:35:31 +10:00
1
27 KiB
Assets (1)
Versions (3) View all
0.1.5 2026-10-08
0.1.1 2026-09-26
0.1.0 2026-09-26