Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Very Simple Queue is a job queue with a simple API and support for sqlite3, redis and mysql

License

Notifications You must be signed in to change notification settings

jimenezmaximiliano/very-simple-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Very Simple Queue is a job queue with a simple API and support for sqlite3, redis and mysql

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published