1.6.4 • Published 3 months ago

very-simple-queue v1.6.4

Weekly downloads
47
License
ISC
Repository
github
Last release
3 months ago

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

1.6.4

3 months ago

1.6.3

9 months ago

1.6.2

11 months ago

1.4.6

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.5

1 year ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.4.0

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.17

2 years ago

1.2.16

3 years ago

1.2.14

3 years ago

1.2.13

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.10

4 years ago

1.2.3

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago