Package Exports
- pg-boss
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pg-boss) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Queueing jobs in Node.js using PostgreSQL like a boss.
var PgBoss = require('pg-boss');
var boss = new PgBoss('postgres://username:password@localhost/database');
boss.start()
.then(ready)
.catch(error => console.error(error));
function ready() {
boss.publish('work', {message: 'stuff'})
.then(jobId => console.log(`sent job ${jobId}`));
boss.subscribe('work', (job, done) => {
console.log(`got job ${job.name} (${job.id}) ${JSON.stringify(job.data)}`);
done().then(() => console.log('Confirmed done'));
});
}##Installation
$ npm install pg-boss
##Features
- Guaranteed delivery and finalizing of jobs using a promise API
- Delayed jobs
- Job retries
- Job throttling (rate limiting)
- Distributed and/or clustered workers
- Automatic provisioning of required storage into a dedicated schema
- Automatic monitoring for expired jobs
- Automatic archiving for completed jobs
##Requirements
- Node 0.10 or higher (It may work on older versions, but who's using < 0.10? :)
- Postgres 9.5 or higher (see background below for rationale)
##Documentation It's actually taking longer to document this than actually write it. :)
- API Docs - (in progress)
##Background pg-boss was created to leverage recent additions in PostreSQL 9.5 (specifically SKIP LOCKED and upserts) which significantly enhances it's ability to act as a reliable, distributed message queue. For example, I have a performance test which regularly completes 1000 jobs per second (a bit longer in CI of course) once SKIP LOCKED was added to my job fetch CTE.