0.2.6 • Published 3 years ago

bull-reloadable-config v0.2.6

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

Bull reloadable config

This libray allow you to manage a bull configuration as some code. Each time your application is redeployed, you can reload the configuration of the jobs.

This is usefulll for delay/cron or schedulded jobs

Usage

npm i bull-reloadable-config

In your projet, reload your config this way :

const queueOptions = { redis: new Redis() }; // We can use here createClient in order to share your redis connections

import { reloadConfig } from 'bull-reloadable-config';

const userConfigs = [
    {
        data: { _version: '1.0.4', type: 'logout', logoutUserId: 'userId' },
        opts: { jobId, delay: 60_000 },
    },
     {
        data: { _version: '1.0.4', type: 'logout', logoutUserId: 'otherUserId' },
        opts: { jobId, delay: 3600_000 },
    },
];
await reloadConfig('userAutoLogQueue', queueOptions, configs);

const userConfigs = [
    {
        data: { _version: '1.0.4', ...paymentsData },
        opts: { jobId: 'recurrentPaiement147678', repeat: {cron: '15 3 * * *'} },
    },
];

await reloadConfig('paymentsQueue', queueOptions, configs);

The reloadConfig method

paramdescriptionrequireddefault
queue nameThe bull queue nametrue-
queue optionsThe bull queue optionstrue-
configsAn array of config objects (see below)true-
deleteExtraJobsIf true, the job that exist in the queue but not in configs will be deletedfalsefalse
concurrencyThe number of concurrent operations on the queues (only for updates and remove)false5000

The Config object

keydescriptiondefault value
data.versionThe semver version of the job config-
opts.jobIdA uniq identifier for the job-
nameThe job nameundefined
forceIf true, the job will be reloaded even if its new version is lower that the current onefalse

Performance consideration

This lib is tested with huge amount of jobs (10,000 in the tests) in less than a dozen of seconds.

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago