This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

very-simple-queue

1.6.4 • Public • Published

Very Simple Queue

CI

Very Simple Queue is a job queue with a simple API and support for:

  • redis
  • mysql
  • sqlite3

Installation

npm install very-simple-queue

or

yarn add very-simple-queue

Usage

Instantiating the VerySimpleQueue facade

const VerySimpleQueue = require('very-simple-queue');

const verySimpleQueue = new VerySimpleQueue('sqlite3', {
  filePath: '/tmp/testdb.sqlite3',
});

Usage example

await verySimpleQueue.createJobsDbStructure(); // Only the first time
await verySimpleQueue.pushJob({ obladi: "oblada" }, 'myQueue');
await verySimpleQueue.handleJob((payload) => console.log(payload), 'myQueue');

Workers

Using the work function

await verySimpleQueue.work((payload) => console.log(payload), { queue: 'myQueue' });
Default values for worker settings
{
  queue: 'default',
  restTimeInSeconds: 5,
  logResults: false,
  limit: null, // Number of jobs to handle before stopping
  logErrors: false,
  stopOnFailure: false,
  loggerFunction: console.log,
}
Graceful shutdown

After getting a signal to shut down your application, you can stop workers to grab another job like this:

verySimpleQueue.shutdown();

Existing jobs will be finished.

Other functions

Handle job by UUID

await verySimpleQueue.handleJobByUuid((payload) => console.log(payload), 'myQueue', 'uuid');

Custom workers

You can create custom workers using the provided functions to handle jobs. You only need a loop.

License

ISC

Package Sidebar

Install

npm i very-simple-queue

Weekly Downloads

17

Version

1.6.4

License

ISC

Unpacked Size

38.6 kB

Total Files

17

Last publish

Collaborators

  • jimenezmaximiliano