@lucid-softworks/queue-store-postgres
v0.1.0
Published
SKIP LOCKED durable QueueStore for pg-compatible PostgreSQL pools.
Maintainers
Readme
@lucid-softworks/queue-store-postgres
A durable PostgreSQL QueueStore using row locks and SKIP LOCKED. The package
accepts a structural pool interface and does not force a PostgreSQL driver
version.
import pg from "pg";
import { PostgresQueueStore } from "@lucid-softworks/queue-store-postgres";
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
const store = new PostgresQueueStore(pool);
await store.migrate();migrate creates the table, ready-job index, and partial unique deduplication
index. Run it during deployment rather than from every worker when schema
changes are centrally managed.
Claims open a dedicated pool connection, recover expired leases, select one
eligible row with FOR UPDATE SKIP LOCKED, persist its lease, and commit before
releasing the connection. Errors roll back and always release the connection.
This permits multiple workers to claim concurrently without blocking on the
same ready job.
The exported PostgresQueueDatabase, PostgresQueueConnection, and result
types describe the minimal driver contract.
