postqueue is a simple postgres-backed queue. Currently, it can process about 1360 jobs per second with a tiny bit of overhead.
yarn add postqueueconst{ Queue }=require('postqueue')constKnexfile=require('./knexfile')constknex=require('knex')constTestQueue=newQueue('test-queue',knex(Knexfile['development']))TestQueue.process(async(j)=>{console.log(`processing: ${JSON.stringify(j.data)}`)return{gotback: 'data'}});(async()=>{// normal job, will not delete results until done()constjob=awaitTestQueue.add({test: 'hello!',},{deleteOnAcknowledged: false})// this will print out the output from the jobconsole.log(`processed: ${JSON.stringify(awaitjob.done())}`)// recurring job, will not save resultsawaitTestQueue.add({test: 'recur hello!',},{everySecs: 5// runs every 5 seconds})})()Migrations can be done using setupTables and dropTables:
const{ setupTables, dropTables }=require('../../dist')exports.up=function(knex){returnsetupTables(knex)};exports.down=function(knex){returndropTables(knex)};