@seta-labs/nestjs-bullmq 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/bullmq.constants.d.ts +2 -2
- package/dist/bullmq.constants.js +2 -2
- package/dist/bullmq.constants.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/metrics/queue-metrics.module.d.ts +3 -1
- package/dist/metrics/queue-metrics.module.js +38 -7
- package/dist/metrics/queue-metrics.module.js.map +1 -1
- package/dist/metrics/queue-metrics.service.d.ts +9 -4
- package/dist/metrics/queue-metrics.service.js +15 -9
- package/dist/metrics/queue-metrics.service.js.map +1 -1
- package/dist/types/queue-metrics-options.type.d.ts +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,6 +71,17 @@ QueueMetricsModule.forRoot({
|
|
|
71
71
|
}),
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
With the connection in the app's typed environment, build the options from it:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
QueueMetricsModule.forRootAsync({
|
|
78
|
+
imports: [ConfigModule],
|
|
79
|
+
inject: [ENV],
|
|
80
|
+
useFactory: (env: Env) => ({ connection: redisConnection(env), queues: QUEUE_NAMES }),
|
|
81
|
+
decorators: [Public()],
|
|
82
|
+
}),
|
|
83
|
+
```
|
|
84
|
+
|
|
74
85
|
| Series | Type | |
|
|
75
86
|
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------------------------- |
|
|
76
87
|
| `bullmq_job_count{queue,state}` | gauge | jobs per state: `waiting`, `active`, `delayed`, `prioritized`, `waiting-children`, `completed`, `failed` |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const QUEUE_EVENTS_OPTIONS: unique symbol;
|
|
2
2
|
export declare const QUEUE_METRICS_OPTIONS: unique symbol;
|
|
3
|
-
/**
|
|
4
|
-
export declare const
|
|
3
|
+
/** Opens the `Queue` of one configured name for `/metrics`. */
|
|
4
|
+
export declare const QUEUE_METRICS_QUEUE_FACTORY: unique symbol;
|
|
5
5
|
export declare const DEFAULT_SUMMARY_INTERVAL_MS = 60000;
|
|
6
6
|
export declare const DEFAULT_METRICS_TIMEOUT_MS = 5000;
|
|
7
7
|
/** Prometheus text exposition format, version 0.0.4. */
|
package/dist/bullmq.constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const QUEUE_EVENTS_OPTIONS = Symbol('QUEUE_EVENTS_OPTIONS');
|
|
2
2
|
export const QUEUE_METRICS_OPTIONS = Symbol('QUEUE_METRICS_OPTIONS');
|
|
3
|
-
/**
|
|
4
|
-
export const
|
|
3
|
+
/** Opens the `Queue` of one configured name for `/metrics`. */
|
|
4
|
+
export const QUEUE_METRICS_QUEUE_FACTORY = Symbol('QUEUE_METRICS_QUEUE_FACTORY');
|
|
5
5
|
export const DEFAULT_SUMMARY_INTERVAL_MS = 60_000;
|
|
6
6
|
export const DEFAULT_METRICS_TIMEOUT_MS = 5_000;
|
|
7
7
|
/** Prometheus text exposition format, version 0.0.4. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullmq.constants.js","sourceRoot":"","sources":["../src/bullmq.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAErE
|
|
1
|
+
{"version":3,"file":"bullmq.constants.js","sourceRoot":"","sources":["../src/bullmq.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAErE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAEjF,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAElD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEhD,wDAAwD;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAG,0CAA0C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { QueueMetricsService } from './metrics/queue-metrics.service.js';
|
|
|
5
5
|
export { queueDefaults, workerDefaults } from './queue-defaults.util.js';
|
|
6
6
|
export type { ObservedWorker } from './types/observed-worker.type.js';
|
|
7
7
|
export type { QueueEventsOptions } from './types/queue-events-options.type.js';
|
|
8
|
-
export type { QueueMetricsOptions } from './types/queue-metrics-options.type.js';
|
|
8
|
+
export type { QueueMetricsAsyncOptions, QueueMetricsConfig, QueueMetricsOptions, } from './types/queue-metrics-options.type.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DynamicModule } from '@nestjs/common';
|
|
2
|
-
import type { QueueMetricsOptions } from '../types/queue-metrics-options.type.js';
|
|
2
|
+
import type { QueueMetricsAsyncOptions, QueueMetricsOptions } from '../types/queue-metrics-options.type.js';
|
|
3
3
|
/**
|
|
4
4
|
* `GET /metrics`: the configured queues in the Prometheus text format. Import
|
|
5
5
|
* it in a role whose port no ingress publishes (a headless role on its health
|
|
@@ -7,4 +7,6 @@ import type { QueueMetricsOptions } from '../types/queue-metrics-options.type.js
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class QueueMetricsModule {
|
|
9
9
|
static forRoot(options: QueueMetricsOptions): DynamicModule;
|
|
10
|
+
/** Same as `forRoot`, with the options built from injected providers (the app's environment). */
|
|
11
|
+
static forRootAsync(options: QueueMetricsAsyncOptions): DynamicModule;
|
|
10
12
|
}
|
|
@@ -5,11 +5,30 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var QueueMetricsModule_1;
|
|
8
|
-
import { Module } from '@nestjs/common';
|
|
8
|
+
import { Logger, Module } from '@nestjs/common';
|
|
9
9
|
import { Queue } from 'bullmq';
|
|
10
|
-
import { QUEUE_METRICS_OPTIONS,
|
|
10
|
+
import { QUEUE_METRICS_OPTIONS, QUEUE_METRICS_QUEUE_FACTORY } from '../bullmq.constants.js';
|
|
11
11
|
import { createQueueMetricsController } from './queue-metrics.controller.js';
|
|
12
12
|
import { QueueMetricsService } from './queue-metrics.service.js';
|
|
13
|
+
const logger = new Logger('QueueMetricsModule');
|
|
14
|
+
/**
|
|
15
|
+
* One `Queue` per configured name, closed by `QueueMetricsService` on
|
|
16
|
+
* shutdown. A queue without an `error` listener would turn a Redis outage
|
|
17
|
+
* into an uncaught exception: the listener only traces it, since the failed
|
|
18
|
+
* scrape already warns once per minute.
|
|
19
|
+
*/
|
|
20
|
+
const QUEUE_FACTORY_PROVIDER = {
|
|
21
|
+
provide: QUEUE_METRICS_QUEUE_FACTORY,
|
|
22
|
+
useFactory: (options) => (name) => {
|
|
23
|
+
const queue = new Queue(name, {
|
|
24
|
+
connection: options.connection,
|
|
25
|
+
prefix: options.prefix,
|
|
26
|
+
});
|
|
27
|
+
queue.on('error', (err) => logger.debug({ err, queue: name }, 'queue metrics connection failed'));
|
|
28
|
+
return queue;
|
|
29
|
+
},
|
|
30
|
+
inject: [QUEUE_METRICS_OPTIONS],
|
|
31
|
+
};
|
|
13
32
|
/**
|
|
14
33
|
* `GET /metrics`: the configured queues in the Prometheus text format. Import
|
|
15
34
|
* it in a role whose port no ingress publishes (a headless role on its health
|
|
@@ -22,13 +41,25 @@ let QueueMetricsModule = QueueMetricsModule_1 = class QueueMetricsModule {
|
|
|
22
41
|
controllers: [createQueueMetricsController(options.decorators)],
|
|
23
42
|
providers: [
|
|
24
43
|
{ provide: QUEUE_METRICS_OPTIONS, useValue: options },
|
|
44
|
+
QUEUE_FACTORY_PROVIDER,
|
|
45
|
+
QueueMetricsService,
|
|
46
|
+
],
|
|
47
|
+
exports: [QueueMetricsService],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Same as `forRoot`, with the options built from injected providers (the app's environment). */
|
|
51
|
+
static forRootAsync(options) {
|
|
52
|
+
return {
|
|
53
|
+
module: QueueMetricsModule_1,
|
|
54
|
+
imports: options.imports ?? [],
|
|
55
|
+
controllers: [createQueueMetricsController(options.decorators)],
|
|
56
|
+
providers: [
|
|
25
57
|
{
|
|
26
|
-
provide:
|
|
27
|
-
useFactory:
|
|
28
|
-
|
|
29
|
-
prefix: options.prefix,
|
|
30
|
-
})),
|
|
58
|
+
provide: QUEUE_METRICS_OPTIONS,
|
|
59
|
+
useFactory: options.useFactory,
|
|
60
|
+
inject: options.inject ?? [],
|
|
31
61
|
},
|
|
62
|
+
QUEUE_FACTORY_PROVIDER,
|
|
32
63
|
QueueMetricsService,
|
|
33
64
|
],
|
|
34
65
|
exports: [QueueMetricsService],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-metrics.module.js","sourceRoot":"","sources":["../../src/metrics/queue-metrics.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"queue-metrics.module.js","sourceRoot":"","sources":["../../src/metrics/queue-metrics.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAO5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAA4B,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE3F,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAEhD;;;;;GAKG;AAC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AAC,MAAM,IAAI,EAAE;iBAC/B;gBACD,sBAAsB;gBACtB,mBAAmB;aACtB;YACD,OAAO,EAAE,CAAC,mBAAmB,CAAC;SACjC,CAAC;IACN,CAAC;CACJ,CAAA;AAhCY,kBAAkB;IAD9B,MAAM,CAAC,EAAE,CAAC;GACE,kBAAkB,CAgC9B"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { type OnModuleDestroy } from '@nestjs/common';
|
|
2
2
|
import type { Queue } from 'bullmq';
|
|
3
|
-
import type {
|
|
3
|
+
import type { QueueMetricsConfig } from '../types/queue-metrics-options.type.js';
|
|
4
4
|
/** The calls `/metrics` makes on a queue. */
|
|
5
5
|
export type MetricsQueue = Pick<Queue, 'name' | 'getJobCounts' | 'getMetrics' | 'isPaused' | 'close'>;
|
|
6
|
+
/** Opens the queue of one name; called on the first scrape, never at boot. */
|
|
7
|
+
export type MetricsQueueFactory = (name: string) => MetricsQueue;
|
|
6
8
|
/**
|
|
7
9
|
* Reads the configured queues for `/metrics`. The counters live in Redis and
|
|
8
|
-
* are the same whichever pod reads them.
|
|
10
|
+
* are the same whichever pod reads them. The queues open on the first scrape:
|
|
11
|
+
* booting the role (or a test of its module) connects to nothing.
|
|
9
12
|
*/
|
|
10
13
|
export declare class QueueMetricsService implements OnModuleDestroy {
|
|
11
14
|
private readonly options;
|
|
12
|
-
private readonly
|
|
15
|
+
private readonly open;
|
|
13
16
|
private readonly logger;
|
|
14
|
-
|
|
17
|
+
private queues?;
|
|
18
|
+
constructor(options: QueueMetricsConfig, open: MetricsQueueFactory);
|
|
19
|
+
private getQueues;
|
|
15
20
|
/** Every queue in the Prometheus text format; a 503 when Redis does not answer in time. */
|
|
16
21
|
render(): Promise<string>;
|
|
17
22
|
onModuleDestroy(): Promise<void>;
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
var QueueMetricsService_1;
|
|
14
14
|
import { Inject, Injectable, Logger, ServiceUnavailableException, } from '@nestjs/common';
|
|
15
|
-
import { DEFAULT_METRICS_TIMEOUT_MS, QUEUE_METRICS_OPTIONS,
|
|
15
|
+
import { DEFAULT_METRICS_TIMEOUT_MS, QUEUE_METRICS_OPTIONS, QUEUE_METRICS_QUEUE_FACTORY, } from '../bullmq.constants.js';
|
|
16
16
|
import { renderPrometheus } from './prometheus.util.js';
|
|
17
17
|
async function snapshotOf(queue) {
|
|
18
18
|
const [counts, completed, failed, isPaused] = await Promise.all([
|
|
@@ -31,15 +31,21 @@ async function snapshotOf(queue) {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Reads the configured queues for `/metrics`. The counters live in Redis and
|
|
34
|
-
* are the same whichever pod reads them.
|
|
34
|
+
* are the same whichever pod reads them. The queues open on the first scrape:
|
|
35
|
+
* booting the role (or a test of its module) connects to nothing.
|
|
35
36
|
*/
|
|
36
37
|
let QueueMetricsService = QueueMetricsService_1 = class QueueMetricsService {
|
|
37
38
|
options;
|
|
38
|
-
|
|
39
|
+
open;
|
|
39
40
|
logger = new Logger(QueueMetricsService_1.name);
|
|
40
|
-
|
|
41
|
+
queues;
|
|
42
|
+
constructor(options, open) {
|
|
41
43
|
this.options = options;
|
|
42
|
-
this.
|
|
44
|
+
this.open = open;
|
|
45
|
+
}
|
|
46
|
+
getQueues() {
|
|
47
|
+
this.queues ??= this.options.queues.map((name) => this.open(name));
|
|
48
|
+
return this.queues;
|
|
43
49
|
}
|
|
44
50
|
/** Every queue in the Prometheus text format; a 503 when Redis does not answer in time. */
|
|
45
51
|
async render() {
|
|
@@ -50,7 +56,7 @@ let QueueMetricsService = QueueMetricsService_1 = class QueueMetricsService {
|
|
|
50
56
|
});
|
|
51
57
|
try {
|
|
52
58
|
const snapshots = await Promise.race([
|
|
53
|
-
Promise.all(this.
|
|
59
|
+
Promise.all(this.getQueues().map(snapshotOf)),
|
|
54
60
|
timeout,
|
|
55
61
|
]);
|
|
56
62
|
return renderPrometheus(snapshots);
|
|
@@ -64,14 +70,14 @@ let QueueMetricsService = QueueMetricsService_1 = class QueueMetricsService {
|
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
async onModuleDestroy() {
|
|
67
|
-
await Promise.all(this.queues.map((queue) => queue.close()));
|
|
73
|
+
await Promise.all((this.queues ?? []).map((queue) => queue.close()));
|
|
68
74
|
}
|
|
69
75
|
};
|
|
70
76
|
QueueMetricsService = QueueMetricsService_1 = __decorate([
|
|
71
77
|
Injectable(),
|
|
72
78
|
__param(0, Inject(QUEUE_METRICS_OPTIONS)),
|
|
73
|
-
__param(1, Inject(
|
|
74
|
-
__metadata("design:paramtypes", [Object,
|
|
79
|
+
__param(1, Inject(QUEUE_METRICS_QUEUE_FACTORY)),
|
|
80
|
+
__metadata("design:paramtypes", [Object, Function])
|
|
75
81
|
], QueueMetricsService);
|
|
76
82
|
export { QueueMetricsService };
|
|
77
83
|
//# sourceMappingURL=queue-metrics.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-metrics.service.js","sourceRoot":"","sources":["../../src/metrics/queue-metrics.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EACH,MAAM,EACN,UAAU,EACV,MAAM,EAEN,2BAA2B,GAC9B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACH,0BAA0B,EAC1B,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"queue-metrics.service.js","sourceRoot":"","sources":["../../src/metrics/queue-metrics.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EACH,MAAM,EACN,UAAU,EACV,MAAM,EAEN,2BAA2B,GAC9B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACH,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,GAC9B,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAWxD,KAAK,UAAU,UAAU,CAAC,KAAmB;IACzC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GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0BAA0B,SAAS,KAAK,CAAC,CAAC,EACjE,SAAS,CACZ,CAAC;QACN,CAAC,CAAC,CAAC;QACH,IAAI,CAAC;YACD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAC7C,OAAO;aACV,CAAC,CAAC;YACH,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC;YACxF,MAAM,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,CAAC;QACvE,CAAC;gBAAS,CAAC;YACP,YAAY,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,eAAe;QACjB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;CACJ,CAAA;AAzCY,mBAAmB;IAD/B,UAAU,EAAE;IAMJ,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC7B,WAAA,MAAM,CAAC,2BAA2B,CAAC,CAAA;;GAN/B,mBAAmB,CAyC/B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FactoryProvider, ModuleMetadata } from '@nestjs/common';
|
|
1
2
|
import type { ConnectionOptions } from 'bullmq';
|
|
2
3
|
export interface QueueMetricsOptions {
|
|
3
4
|
/** Redis of the queues; an ioredis instance is shared by every queue read. */
|
|
@@ -11,3 +12,13 @@ export interface QueueMetricsOptions {
|
|
|
11
12
|
/** Time allowed to read every queue before the scrape fails with a 503. Default `5_000`. */
|
|
12
13
|
timeoutMs?: number;
|
|
13
14
|
}
|
|
15
|
+
/** What `forRootAsync` resolves: everything but the decorators, which the route needs when the module is built. */
|
|
16
|
+
export type QueueMetricsConfig = Omit<QueueMetricsOptions, 'decorators'>;
|
|
17
|
+
export interface QueueMetricsAsyncOptions {
|
|
18
|
+
/** Modules that export what `inject` names, e.g. the app's config module. */
|
|
19
|
+
imports?: ModuleMetadata['imports'];
|
|
20
|
+
inject?: FactoryProvider['inject'];
|
|
21
|
+
/** Builds the options from the injected providers, e.g. the app's typed environment. */
|
|
22
|
+
useFactory: (...args: never[]) => QueueMetricsConfig | Promise<QueueMetricsConfig>;
|
|
23
|
+
decorators?: MethodDecorator[];
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seta-labs/nestjs-bullmq",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "BullMQ queues for NestJS apps: default job and worker options, one log line per job outcome with a per-minute summary per queue, and the queue counters in the Prometheus format",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|