Multi-transport Background Queue Package for Node.js. Will support Redis and 'Sync' out of the box.
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!)
```ecmascript 6
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();
```