queuely

0.1.2 • Public • Published

Queuely

Queuely is a multi-transport queue package for Node.js. It supports a 'sync' and 'array' driver out of the box, which lets you get set up quickly.

If you want to full power of a distributed, backend queue, you can pull in a different transport from another package.

Note: This package is going to hit the prime time soon but I don't yet run it in production. If you want to take the risk, please let me know if any bugs or issues arise. Otherwise I'll update this when it's ready.

Official Transport Roadmap:

[] Redis - queuely-redis-transport (not yet built - but is a priority!)

Features

  • Queue and process jobs and events in sync or in background
  • Dispatch jobs and events on to specific queues
  • Support job/event retry via transport configuration
  • Worker class to watch a queue and process jobs
    • Interval to poll
    • Process jobs concurrently (as jobs are asynchronous) with max limit
    • Mark jobs as completed
    • Mark jobs as failed (after max retries)

Usage

import queue from 'queuely';
import Job from 'queuely/dispatchables/Job'
import Event from 'queuely/dispatchables/Event'
 
// To use another transport, import the transport, then use it as a function
// with the necessary options
queue.use(
  redis({
     host: 'localhost',
     port: 6379,
     username: 'me',
     password: 'secretpass',
     tries: 3,
  })
)
 
class MyJob extends Job {};
class MyEvent extends Event {};
 
queue.on(MyJob, (job, resolve, reject) => {
    // perform your logic
    
    resolve();
    
    // if it is possible to have an Error thrown or for the job
    // to be rejected, you should wrap this handler callback 
    // in a promise with a .catch() to safely store it away.
    
    // Not doing so may result in your queue/workers crashing unexpectedly.
});
 
// Dispatch jobs using a variety of options:
let job = new MyJob();
queue.dispatch(job).onQueue('sla-customers').toBackground();
queue.dispatch(job).toBackground();
queue.dispatch(job).now();

Package Sidebar

Install

npm i queuely

Weekly Downloads

3

Version

0.1.2

License

MIT

Last publish

Collaborators

  • cimrie