Socket
Book a DemoInstallSign in
Socket

egg-delayed-queue

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-delayed-queue

A priority job queue backed by redis, built for eggjs.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

egg-delayed-queue

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

A priority queue queue backed by redis, built for eggjs.

Install

$ yarn add egg-delayed-queue

Usage

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

Configuration

// {app_root}/config/config.default.js
'use strict';
exports.queue = {
  client: {
    queuePrefix: 'q',
    redis: {
      port: 6379,
      host: '127.0.0.1',
      auth: '',
      db: 3,
      // see https://github.com/mranney/node_redis#rediscreateclient
      options: {
      },
    },
  },
  // clients: {}
};

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

Example

// 在 app.js 里面调用 如果需要用到ctx 可以 const ctx = app.createAnonymousContext();
app.queue.process('orderNo', (job, done) => {
  // 这里可以调用service里面的方法来消费这些信息
  const ctx = app.createAnonymousContext();
    ctx.service.home.dealOrder(job.data, done); // dealOrder是自定义的方法
});

// 在需要的地方订阅一个消息
app.queue.create('orderNo', {
    orderNo: '1111111',
    create_time: Date.now()
}).delay(milliseconds) // 延时多少毫秒
  .save();

form more config please see here

Questions & Suggestions

Please open an issue here.

License

MIT

Keywords

egg

FAQs

Package last updated on 02 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts