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

0.0.4 • Public • Published

egg-bull

🥚 Egg.js middleware for bull

Install

yarn add @zhuowenli/egg-bull

Usage

Plugin

// {app_root}/config/plugin.ts
const plugin: EggPlugin = {
    bull: {
        enable: true,
        package: '@zhuowenli/egg-bull',
    },
};

Configuration

Single queue

// {app_root}/config/config.default.ts
config.bull = {
    client: {
        name: 'queue',
        redis: {
            host: 'localhost',
            port: 6379,
            db: 0,
        },
    },
};

Multiple queue (recommended)

// {app_root}/config/config.default.ts
config.bull = {
    clients: {
        q1: { name: 'q1' },
        q2: { name: 'q2' },
    },
    default: {
        redis: {
            host: 'localhost',
            port: 6379,
            db: 0,
        },
    },
};

Example

app.bull.process(job => {
    console.log(job.data.job1); // 'this is a job'
});

app.bull.add({ job1: 'this is a job' });

For Bull's api read Reference for more details.

Package Sidebar

Install

npm i @zhuowenli/egg-bull

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

6.94 kB

Total Files

6

Last publish

Collaborators

  • caigua
  • zwlo