@knetik/micro-queue
This package adds redis queue support using Bull Queue to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor.
Last updated 24 days ago by knetik .
MIT · Original npm · Tarball · package.json
$ cnpm install @knetik/micro-queue 
SYNC missed versions from official npm registry.

Knetik Micro Queue

This package adds redis queue support using Bull Queue to any micro-core application as a multi tenant adaptor.

When a customer connects to a micro-core application, the required app_id is passed into the adaptor initializer and used as the context for any jobs created using the micro queue Job class interface.

Setup

Install the @knetik/micro-queue package

yarn add @knetik/micro-queue

Add the Adaptor to your config/environments/{env}.json

"ADAPTORS": [
  "@knetik/micro-queue"
]

Add the REDIS_HOST param as well

"REDIS_HOST": "127.0.0.1"

Job Generator

$ yarn run micro-queue generate {job_name}

A file is generated in app/jobs/{job_name}.job.js

if the {job_name} id some_long_process, the contents of app/jobs/{job_name}.job.js are:

const { JobBase } = require('@knetik/micro-queue');

module.exports = class SomeLongProcessJob extends JobBase {
  static perform(App, params, progress) {
    App.Logger.info('performing SomeLongProcessJob');

    /* ====== EXAMPLE USAGE ========= */
    App.Logger.info('SomeLongProcessJob', params);

    let pending = 100;
    let total = 0;

    // Jobs must return a Promise
    return new Promise((resolve, reject) => {
      const interval = setInterval(() => {
        pending -= 1;
        total += 1;

        App.Logger.info('SomeLongProcessJob progress', pending);

        // use progress to increment the jobs progress status
        progress(total);

        if (!pending) {
          resolve('done');
          clearInterval(interval);
        }
      }, 1000);
    });
    /* ====== END EXAMPLE USAGE ========= */
  }
};

// Set the max concurrency value for this job.
module.exports.concurrency = 50;

Usage

The Adaptor is added to the Micro Core application at App.Queue. Use App.Queue#get to load job classes form the App's initialized jobs.

const Job = App.Queue.get('SomeLongProcessJob');

Call perform_later on the Job class passing in the job data and the job options

const data = { hi: 'there' };
const options = {};

Job.perform_later(data, options);

Queue UI

if the Micro Express Adaptor is installed the Queue management UI is mounted at /arena. Visit it in the browser for handy job management.

Documentation

More info is available in the DOCS

Current Tags

  • 3.0.74                                ...           latest (24 days ago)

88 Versions

  • 3.0.74                                ...           24 days ago
  • 3.0.73                                ...           a month ago
  • 3.0.72                                ...           a month ago
  • 3.0.71                                ...           a month ago
  • 3.0.70                                ...           a month ago
  • 3.0.69                                ...           a month ago
  • 3.0.68                                ...           a month ago
  • 3.0.67                                ...           2 months ago
  • 3.0.66                                ...           2 months ago
  • 3.0.65                                ...           2 months ago
  • 3.0.64                                ...           3 months ago
  • 3.0.63                                ...           3 months ago
  • 3.0.62                                ...           5 months ago
  • 3.0.61                                ...           5 months ago
  • 3.0.60                                ...           5 months ago
  • 3.0.58                                ...           6 months ago
  • 3.0.57                                ...           6 months ago
  • 3.0.56                                ...           6 months ago
  • 3.0.55                                ...           7 months ago
  • 3.0.54                                ...           7 months ago
  • 3.0.53                                ...           7 months ago
  • 3.0.52                                ...           9 months ago
  • 3.0.51                                ...           9 months ago
  • 3.0.50                                ...           9 months ago
  • 3.0.49                                ...           9 months ago
  • 3.0.48                                ...           10 months ago
  • 3.0.47                                ...           10 months ago
  • 3.0.46                                ...           10 months ago
  • 3.0.45                                ...           10 months ago
  • 3.0.44                                ...           10 months ago
  • 3.0.43                                ...           10 months ago
  • 3.0.42                                ...           10 months ago
  • 3.0.41                                ...           10 months ago
  • 3.0.40                                ...           10 months ago
  • 3.0.39                                ...           a year ago
  • 3.0.38                                ...           a year ago
  • 3.0.37                                ...           a year ago
  • 3.0.36                                ...           a year ago
  • 3.0.35                                ...           a year ago
  • 3.0.34                                ...           a year ago
  • 3.0.33                                ...           a year ago
  • 3.0.32                                ...           a year ago
  • 3.0.31                                ...           a year ago
  • 3.0.30                                ...           a year ago
  • 3.0.29                                ...           a year ago
  • 3.0.28                                ...           a year ago
  • 3.0.27                                ...           a year ago
  • 3.0.26                                ...           a year ago
  • 3.0.25                                ...           a year ago
  • 3.0.24                                ...           a year ago
  • 3.0.23                                ...           a year ago
  • 3.0.22                                ...           a year ago
  • 3.0.21                                ...           a year ago
  • 3.0.20                                ...           a year ago
  • 3.0.19                                ...           a year ago
  • 2.1.10                                ...           a year ago
  • 2.1.9                                ...           a year ago
  • 2.1.7                                ...           a year ago
  • 2.1.6                                ...           a year ago
  • 3.0.17                                ...           a year ago
  • 2.1.5                                ...           a year ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 3.0.16                                ...           a year ago
  • 3.0.15                                ...           a year ago
  • 3.0.14                                ...           a year ago
  • 3.0.13                                ...           a year ago
  • 3.0.11                                ...           a year ago
  • 3.0.10                                ...           a year ago
  • 3.0.9                                ...           a year ago
  • 3.0.7                                ...           a year ago
  • 3.0.6                                ...           a year ago
  • 3.0.5                                ...           a year ago
  • 3.0.4                                ...           a year ago
  • 3.0.3                                ...           a year ago
  • 3.0.2                                ...           a year ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.24                                ...           a year ago
  • 2.0.23                                ...           a year ago
  • 2.0.22                                ...           a year ago
  • 2.0.21                                ...           a year ago
  • 2.0.20                                ...           a year ago
  • 2.0.19                                ...           a year ago
  • 2.0.18                                ...           a year ago
  • 2.0.17                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 88
Last Month 394
Dependencies (9)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |