# postqueue

> Simple, powerful postgres-backed queue

Latest version **2.0.2** (published 2020-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install postqueue
pnpm add postqueue
yarn add postqueue
bun add postqueue
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-01-14 |
| First published | 2020-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | meyer9 |
| Maintainers | meyer9 |

## Links

- npm: https://www.npmjs.com/package/postqueue
- Repository: https://github.com/meyer9/postqueue
- Homepage: https://github.com/meyer9/postqueue#readme
- Issues: https://github.com/meyer9/postqueue/issues
- npm.io page: https://npm.io/package/postqueue

## Dependencies (4)

- [pg](https://npm.io/package/pg.md) ^7.17.1
- [knex](https://npm.io/package/knex.md) ^0.20.7
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [es6-promise](https://npm.io/package/es6-promise.md) ^4.2.8

## Recent versions

- 2.0.2 (latest) — 2020-01-14
- 2.0.1 — 2020-01-14
- 2.0.0 — 2020-01-14
- 1.1.2 — 2020-01-13
- 1.1.1 — 2020-01-13
- 1.1.0 — 2020-01-13

## README

# postqueue

[![Build Status](https://travis-ci.com/meyer9/postqueue.svg?branch=master)](https://travis-ci.com/meyer9/postqueue)

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

## Installation

```bash
yarn add postqueue
```

## Usage

```javascript
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](API.md)

## Migrations

Migrations can be done using `setupTables` and `dropTables`:

```javascript
const { setupTables, dropTables } = require('../../dist')

exports.up = function(knex) {
  return setupTables(knex)
};

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

---
_Source: https://npm.io/package/postqueue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
