3.1.10 • Published 2 days ago

@knetik/micro-queue v3.1.10

Weekly downloads
2
License
MIT
Repository
-
Last release
2 days ago

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

3.1.10

2 days ago

3.1.8

1 year ago

3.1.4

2 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.89

3 years ago

3.0.88

3 years ago

3.0.87

3 years ago

3.0.86

3 years ago

3.0.85

3 years ago

3.0.83

3 years ago

3.0.84

3 years ago

3.0.78

4 years ago

3.0.77

4 years ago

3.0.76

4 years ago

3.0.75

4 years ago

3.0.74

4 years ago

3.0.73

4 years ago

3.0.72

4 years ago

3.0.71

4 years ago

3.0.70

4 years ago

3.0.69

4 years ago

3.0.68

4 years ago

3.0.67

4 years ago

3.0.66

4 years ago

3.0.65

4 years ago

3.0.64

4 years ago

3.0.63

4 years ago

3.0.62

4 years ago

3.0.61

4 years ago

3.0.60

4 years ago

3.0.58

4 years ago

3.0.57

4 years ago

3.0.56

4 years ago

3.0.55

4 years ago

3.0.54

4 years ago

3.0.53

5 years ago

3.0.52

5 years ago

3.0.51

5 years ago

3.0.50

5 years ago

3.0.49

5 years ago

3.0.48

5 years ago

3.0.47

5 years ago

3.0.46

5 years ago

3.0.45

5 years ago

3.0.44

5 years ago

3.0.43

5 years ago

3.0.42

5 years ago

3.0.41

5 years ago

3.0.40

5 years ago

3.0.39

5 years ago

3.0.38

5 years ago

3.0.37

5 years ago

3.0.36

5 years ago

3.0.35

5 years ago

3.0.34

5 years ago

3.0.33

5 years ago

3.0.32

5 years ago

3.0.31

5 years ago

3.0.30

5 years ago

3.0.29

5 years ago

3.0.28

5 years ago

3.0.27

5 years ago

3.0.26

5 years ago

3.0.25

5 years ago

3.0.24

5 years ago

3.0.23

5 years ago

3.0.22

5 years ago

3.0.21

5 years ago

3.0.20

5 years ago

3.0.19

5 years ago

2.1.10

5 years ago

2.1.9

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

3.0.17

5 years ago

2.1.5

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

3.0.16

5 years ago

3.0.15

5 years ago

3.0.14

5 years ago

3.0.13

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.24

5 years ago

2.0.23

5 years ago

2.0.22

5 years ago

2.0.21

5 years ago

2.0.20

5 years ago

2.0.19

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago