0.1.8 • Published 3 years ago

@cran/pg.q v0.1.8

Weekly downloads
-
License
CC-BY-ND-4.0
Repository
-
Last release
3 years ago

Postgres Queue

npm install @cran/pg.q

Distributed Queue Functionality for Postgres

Usage

import { PgQ } from "@cran/pg.q";
import { Pool } from "pg";

const q = new PgQ({
  pool: new Pool(/* ... */),
  async handler ( payload ) {
    // handle payload
  },
  // optional
  target: "default", // ignored if uq is false
  fields: {
    // unique identifier (should be primary key)
    id: "id",
    // unique qualifier (can be false to ignore)
    uq: "uq",
    // retry count field
    rc: "rc",
    // payload
    pl: "pl",
  },
});

;(async function main ( ) {
  process.on("SIGINT", function onSigint ( ) {
    console.log("graceful shutdown...");
    q.stop().then(function afterStop ( ) {
      process.exit(0);
    });
  });

  await q.start();
})().then(
  console.log.bind(console),
  console.error.bind(console)
);
0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.1

4 years ago