Skip to content

afolabiabass/hapi-bull

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hapi-bull

This is a Hapi Plugin to handle queues using Bull connection and setup.

Install

npm install --save @afolabiabass/hapi-bull

Requirements

  • Bull
npm install --save bull

Usage

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;

Options

  • prefix - name attached to redis key
  • redis - Redis
  • queues - Various queues are defined as different process on the redis default connection. Read More

Contribution

PR's are more than welcome!

License

Hapi Bull is open source software licensed as MIT.

About

Hapi (https://hapi.dev/) Plugin to handle queues using Bull (https://github.com/OptimalBits/bull) connection and setup.

Resources

License

Stars

Watchers

Forks

Packages

No packages published