This is a Hapi Plugin to handle queues using Bull connection and setup.
npm install --save @afolabiabass/hapi-bull
- Bull
npm install --save bull
const server = new Hapi.Server();
await server.register({
plugin: require('hapi-bull'),
options: {
prefix: 'default',
redis: {
host: 'localhost',
port: '6379',
password: null,
},
queues: [
{
name: 'sample',
concurrency: 1,
processor: (server, job) => {
console.log(`Starting queue for job ${job.id} with data ${job.data}`);
return new Promise(resolve => setTimeout(resolve, 1000));
},
},
],
},
});
const queue = server.plugins['hapi-bull'].job;
const bull = server.plugins['hapi-bull'].lib;
- prefix - name attached to redis key
- redis - Redis
- queues - Various queues are defined as different process on the redis default connection. Read More
PR's are more than welcome!
Hapi Bull is open source software licensed as MIT.