Skip to content

Repository files navigation

postqueue

Build Status

postqueue is a simple postgres-backed queue. Currently, it can process about 1360 jobs per second with a tiny bit of overhead.

Installation

yarn add postqueue

Usage

const{ 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})})()

Reference

API Docs

Migrations

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)};

About

Postgres-backed job queue for Node

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages