Socket
Book a DemoInstallSign in
Socket

postqueue

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postqueue

Simple, powerful postgres-backed queue

2.0.2
latest
Source
npmnpm
Version published
Weekly downloads
1
-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

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')
const Knexfile = require('./knexfile')
const knex = require('knex')

const TestQueue = new Queue('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()
  const job = await TestQueue.add({
    test: 'hello!',
  }, {
    deleteOnAcknowledged: false
  })

  // this will print out the output from the job
  console.log(`processed: ${JSON.stringify(await job.done())}`)

  // recurring job, will not save results
  await TestQueue.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) {
  return setupTables(knex)
};

exports.down = function(knex) {
  return dropTables(knex)
};

FAQs

Package last updated on 14 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.