diff --git a/README.md b/README.md index 1d5c68b9..5fe3e51e 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,31 @@ Or npm i bull-board ``` -## Hello world +## Hello World + +### Add existing Bull Queue(s) + +When you already defined your queue(s) you can add them using the addQueue function. + +```js +const Queue = require('bull'); + +const someQueue = new Queue(); +const someOtherQueue = new Queue(); + +const { addQueue, setQueues } = require('bull-board') + +addQueue(someQueue).addQueue(someOtherQueue) + +// OR + +setQueues([ + someQueue, + someOtherQueue +]) +``` + +### Configure Queue(s) using bull-board Remember that it depends on Redis as well, so the first step is to configure all of your queues: diff --git a/example.js b/example.js index 269ea1fc..520b7b71 100644 --- a/example.js +++ b/example.js @@ -1,4 +1,4 @@ -const { createQueues, UI } = require('./') +const { createQueues, addQueue, setQueues, UI } = require('./') const app = require('express')() const sleep = t => new Promise(resolve => setTimeout(resolve, t * 1000)) @@ -13,6 +13,9 @@ const redisOptions = { } const run = () => { + addQueue(/* Already defined (bull) queue */); + setQueues([/* Already defined (bull) queues */]); + const queues = createQueues(redisOptions) const example = queues.add('example') diff --git a/index.js b/index.js index f107cf41..0fc930ef 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,16 @@ function UI() { module.exports = { UI: UI(), + setQueues: (queues) => { + queues.forEach((item) => { + this.addQueue(item.queue); + }) + }, + addQueue: (queue) => { + queues[queue.name] = queue + + return this; + }, createQueues: redis => { return { add: (name, opts) => {