This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@skyfury/egg-bull-board
TypeScript icon, indicating that this package has built-in type declarations

4.6.4 • Public • Published

egg bull board

licence open issues typescript node Ecmascript

Install

npm install @skyfury/egg-bull-board -S

bull-board

bull-board

Use

with-egg

'use strict';

const Bull = require('bull')
const { EggAdapter } = require('@skyfury/egg-bull-board')
const { createBullBoard } = require('@bull-board/api');
const { BullAdapter } = require('@bull-board/api/bullAdapter');

const redisOptions = {
  port: 6379,
  host: 'localhost',
  password: '',
  tls: false,
};

const createQueue = (name) => new Bull(name, { connection: redisOptions });

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;

  const bullQueue = createQueue('bull');
  
  const serverAdapter = new EggAdapter();
  createBullBoard({
    queues: [new BullAdapter(bullQueue)],
    serverAdapter,
  });
  serverAdapter.setBasePath('/ui');
  app.use(serverAdapter.registerPlugin());
  
  router.get('/add', async (ctx) => {
    const opts = ctx.query.opts || {};

    if (opts.delay) {
      opts.delay = +opts.delay * 1000; // delay must be a number
    }

    await bullQueue.add('Add', { title: ctx.query.title }, opts);

    ctx.body = {
      ok: true,
    };
  });

  console.log(`For the UI of instance1, open http://localhost:${app.config.cluster.listen.port}/ui`);
  console.log('Make sure Redis is running on port 6379 by default');
  console.log('To populate the queue, run:');
  console.log(`  curl http://localhost:${app.config.cluster.listen.port}/add?title=Example`);
  console.log('To populate the queue with custom options (opts), run:');
  console.log(`  curl http://localhost:${app.config.cluster.listen.port}/add?title=Test&opts[delay]=9`);
};

Package Sidebar

Install

npm i @skyfury/egg-bull-board

Weekly Downloads

0

Version

4.6.4

License

MIT

Unpacked Size

78 kB

Total Files

10

Last publish

Collaborators

  • skyfury