Skip to content

eggjs框架的队列,可设置延时队列和实时队列

License

Notifications You must be signed in to change notification settings

yecao007/egg-ebus

Repository files navigation

egg-ebus

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-ebus --save

Usage

// {app_root}/config/plugin.js
exports.ebus = {
  enable: true,
  package: 'egg-ebus',
};

Configuration

// {app_root}/config/config.default.js
exports.ebus = {
};
例如
exports.ebus = {
    app: true,
    agent: true,
    debug: true,
    concurrency: 2,
    listener: {
      baseDir: 'events',
      options: {
        attempts: 5,
        backoff: {
          delay: 1000,
          type: 'fixed',
        },
      },
    },
    limiter: {
      max: 10,
      duration: 1000
    },
    redis: {
      host: 'localhost',
      port: 6379,
      password: "",
      db: 0,
    },
    queue: {
      default: 'default_bus', // 默认队列名称
      prefix: 'ebus', // 队列前缀
    },
    queues: {
      worker: {
        concurrency: 2,
      },
    },
  }

see config/config.default.js for more detail.

Example

get 获取队列 emit 添加队列
例如 const point = await this.app.ebus.emit("order_action", { ord_no: 123 }, { delay: 1000, removeOnComplete: true, removeOnFail: true });此用例用于发送延时队列

cleanOn (Removes jobs in a specific state, but keeps jobs within a certain grace period) delAll (Completely obliterates a queue and all of its contents.) drain (Removes all jobs that are waiting or delayed, but not active, waiting-children, completed or failed.)

Questions & Suggestions

Please open an issue here.

License

MIT

About

eggjs框架的队列,可设置延时队列和实时队列

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published