3.1.10 • Published 1 year ago

@knetik/micro-queue v3.1.10

Weekly downloads
2
License
MIT
Repository
-
Last release
1 year 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

1 year ago

3.1.8

3 years ago

3.1.4

3 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.89

4 years ago

3.0.88

4 years ago

3.0.87

4 years ago

3.0.86

4 years ago

3.0.85

4 years ago

3.0.83

5 years ago

3.0.84

5 years ago

3.0.78

5 years ago

3.0.77

5 years ago

3.0.76

5 years ago

3.0.75

5 years ago

3.0.74

5 years ago

3.0.73

5 years ago

3.0.72

5 years ago

3.0.71

5 years ago

3.0.70

5 years ago

3.0.69

5 years ago

3.0.68

5 years ago

3.0.67

5 years ago

3.0.66

5 years ago

3.0.65

5 years ago

3.0.64

5 years ago

3.0.63

5 years ago

3.0.62

5 years ago

3.0.61

5 years ago

3.0.60

5 years ago

3.0.58

6 years ago

3.0.57

6 years ago

3.0.56

6 years ago

3.0.55

6 years ago

3.0.54

6 years ago

3.0.53

6 years ago

3.0.52

6 years ago

3.0.51

6 years ago

3.0.50

6 years ago

3.0.49

6 years ago

3.0.48

6 years ago

3.0.47

6 years ago

3.0.46

6 years ago

3.0.45

6 years ago

3.0.44

6 years ago

3.0.43

6 years ago

3.0.42

6 years ago

3.0.41

6 years ago

3.0.40

6 years ago

3.0.39

6 years ago

3.0.38

6 years ago

3.0.37

6 years ago

3.0.36

6 years ago

3.0.35

6 years ago

3.0.34

6 years ago

3.0.33

6 years ago

3.0.32

6 years ago

3.0.31

6 years ago

3.0.30

6 years ago

3.0.29

6 years ago

3.0.28

6 years ago

3.0.27

6 years ago

3.0.26

6 years ago

3.0.25

6 years ago

3.0.24

6 years ago

3.0.23

6 years ago

3.0.22

6 years ago

3.0.21

6 years ago

3.0.20

6 years ago

3.0.19

6 years ago

2.1.10

6 years ago

2.1.9

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

3.0.17

6 years ago

2.1.5

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

3.0.16

6 years ago

3.0.15

6 years ago

3.0.14

6 years ago

3.0.13

6 years ago

3.0.11

6 years ago

3.0.10

6 years ago

3.0.9

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.24

6 years ago

2.0.23

6 years ago

2.0.22

6 years ago

2.0.21

6 years ago

2.0.20

6 years ago

2.0.19

6 years ago

2.0.18

6 years ago

2.0.17

6 years ago