0.0.4 ā€¢ Published 4 years ago

@zhuowenli/egg-bull v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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.