@bymax-one/nest-queue 1.2.10 → 1.2.12
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/CHANGELOG.md +77 -1
- package/README.md +28 -20
- package/dist/server/index.cjs +43 -502
- package/dist/server/index.d.cts +29 -10
- package/dist/server/index.d.ts +29 -10
- package/dist/server/index.mjs +44 -503
- package/package.json +5 -2
package/dist/server/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nestjs_common from '@nestjs/common';
|
|
2
|
-
import { ModuleMetadata, Type, DynamicModule, OnModuleDestroy, HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
+
import { ModuleMetadata, Type, DynamicModule, OnModuleDestroy, OnApplicationShutdown, HttpException, HttpStatus } from '@nestjs/common';
|
|
3
3
|
import { JobsOptions, QueueOptions, Telemetry, BulkJobOptions, Queue, Job, FlowJob, JobNode, FlowProducer, Worker, QueueEvents } from 'bullmq';
|
|
4
4
|
export { FlowJob, FlowProducer, Job, JobNode, JobSchedulerJson, JobsOptions, Queue, QueueEvents, SandboxedJob, Telemetry, Worker } from 'bullmq';
|
|
5
5
|
import { Redis, RedisOptions } from 'ioredis';
|
|
@@ -1013,9 +1013,12 @@ declare class QueueEventsRegistry {
|
|
|
1013
1013
|
|
|
1014
1014
|
/**
|
|
1015
1015
|
* @fileoverview `QueueLifecycle` — the single, ordered graceful-shutdown
|
|
1016
|
-
* orchestrator
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1016
|
+
* orchestrator, split across the two NestJS hooks that bracket the HTTP server.
|
|
1017
|
+
* On `onModuleDestroy` it stops consumption: it drains every worker within a
|
|
1018
|
+
* bounded budget, then closes queue-events and the connections the library
|
|
1019
|
+
* opened for them. On `onApplicationShutdown`, which NestJS runs only after the
|
|
1020
|
+
* HTTP server has stopped, it releases what a request can still be using: the
|
|
1021
|
+
* flow producer, the cached queues, and finally the Queue-role connection.
|
|
1019
1022
|
*
|
|
1020
1023
|
* Delivery is at-least-once: when a worker exceeds the drain budget it is
|
|
1021
1024
|
* force-closed and its in-flight job becomes `stalled` and is retried by another
|
|
@@ -1028,16 +1031,22 @@ declare class QueueEventsRegistry {
|
|
|
1028
1031
|
/**
|
|
1029
1032
|
* Ordered graceful-shutdown service. Implementing the protocol in one place
|
|
1030
1033
|
* guarantees the teardown order — workers drain first, then queue-events, then
|
|
1031
|
-
* the duplicated connections
|
|
1032
|
-
* the Queue-role connection. Every step
|
|
1033
|
-
* failure never aborts the rest of the
|
|
1034
|
+
* the duplicated connections; once the HTTP server has stopped, the flow
|
|
1035
|
+
* producer, the queues, and finally the Queue-role connection. Every step
|
|
1036
|
+
* swallows its own errors so a single failure never aborts the rest of the
|
|
1037
|
+
* sequence.
|
|
1038
|
+
*
|
|
1039
|
+
* Why two hooks: NestJS runs `onModuleDestroy` before it stops the HTTP server,
|
|
1040
|
+
* so a request that is still being served can enqueue a job after that hook has
|
|
1041
|
+
* returned. The producer side (queues, flow producer, Queue-role connection)
|
|
1042
|
+
* therefore waits for `onApplicationShutdown`, while consumption stops early.
|
|
1034
1043
|
*
|
|
1035
1044
|
* Connection ownership: in **Mode B** the library-owned Queue-role client is
|
|
1036
1045
|
* quit by the connection resolver; in **Mode A** that step is a no-op and only
|
|
1037
1046
|
* the duplicated worker/queue-events connections the library created are closed
|
|
1038
1047
|
* — the consumer's shared client is never touched.
|
|
1039
1048
|
*/
|
|
1040
|
-
declare class QueueLifecycle implements OnModuleDestroy {
|
|
1049
|
+
declare class QueueLifecycle implements OnModuleDestroy, OnApplicationShutdown {
|
|
1041
1050
|
private readonly workers;
|
|
1042
1051
|
private readonly events;
|
|
1043
1052
|
private readonly queues;
|
|
@@ -1045,12 +1054,22 @@ declare class QueueLifecycle implements OnModuleDestroy {
|
|
|
1045
1054
|
private readonly connection;
|
|
1046
1055
|
private readonly resolved;
|
|
1047
1056
|
private readonly logger;
|
|
1057
|
+
private startedAt;
|
|
1058
|
+
private forcedWorkers;
|
|
1048
1059
|
constructor(workers: WorkerRegistry, events: QueueEventsRegistry, queues: QueueService, flow: FlowService, connection: ConnectionResolver, resolved: ResolvedQueueOptions);
|
|
1049
1060
|
/**
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1061
|
+
* Stop consumption: drain the workers within the bounded budget, then close
|
|
1062
|
+
* queue-events and the connections the library opened for them. Called by
|
|
1063
|
+
* NestJS when the application context closes (e.g. on `SIGTERM` with shutdown
|
|
1064
|
+
* hooks enabled), before the HTTP server stops.
|
|
1052
1065
|
*/
|
|
1053
1066
|
onModuleDestroy(): Promise<void>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Release the producer side once the HTTP server has stopped: the optional
|
|
1069
|
+
* queue drain, the flow producer, the cached queues, and the Queue-role
|
|
1070
|
+
* connection, then log the total shutdown time.
|
|
1071
|
+
*/
|
|
1072
|
+
onApplicationShutdown(): Promise<void>;
|
|
1054
1073
|
/**
|
|
1055
1074
|
* Close every worker with a bounded drain, force-closing any that exceed the
|
|
1056
1075
|
* budget. Returns the number of workers that had to be force-closed.
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nestjs_common from '@nestjs/common';
|
|
2
|
-
import { ModuleMetadata, Type, DynamicModule, OnModuleDestroy, HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
+
import { ModuleMetadata, Type, DynamicModule, OnModuleDestroy, OnApplicationShutdown, HttpException, HttpStatus } from '@nestjs/common';
|
|
3
3
|
import { JobsOptions, QueueOptions, Telemetry, BulkJobOptions, Queue, Job, FlowJob, JobNode, FlowProducer, Worker, QueueEvents } from 'bullmq';
|
|
4
4
|
export { FlowJob, FlowProducer, Job, JobNode, JobSchedulerJson, JobsOptions, Queue, QueueEvents, SandboxedJob, Telemetry, Worker } from 'bullmq';
|
|
5
5
|
import { Redis, RedisOptions } from 'ioredis';
|
|
@@ -1013,9 +1013,12 @@ declare class QueueEventsRegistry {
|
|
|
1013
1013
|
|
|
1014
1014
|
/**
|
|
1015
1015
|
* @fileoverview `QueueLifecycle` — the single, ordered graceful-shutdown
|
|
1016
|
-
* orchestrator
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1016
|
+
* orchestrator, split across the two NestJS hooks that bracket the HTTP server.
|
|
1017
|
+
* On `onModuleDestroy` it stops consumption: it drains every worker within a
|
|
1018
|
+
* bounded budget, then closes queue-events and the connections the library
|
|
1019
|
+
* opened for them. On `onApplicationShutdown`, which NestJS runs only after the
|
|
1020
|
+
* HTTP server has stopped, it releases what a request can still be using: the
|
|
1021
|
+
* flow producer, the cached queues, and finally the Queue-role connection.
|
|
1019
1022
|
*
|
|
1020
1023
|
* Delivery is at-least-once: when a worker exceeds the drain budget it is
|
|
1021
1024
|
* force-closed and its in-flight job becomes `stalled` and is retried by another
|
|
@@ -1028,16 +1031,22 @@ declare class QueueEventsRegistry {
|
|
|
1028
1031
|
/**
|
|
1029
1032
|
* Ordered graceful-shutdown service. Implementing the protocol in one place
|
|
1030
1033
|
* guarantees the teardown order — workers drain first, then queue-events, then
|
|
1031
|
-
* the duplicated connections
|
|
1032
|
-
* the Queue-role connection. Every step
|
|
1033
|
-
* failure never aborts the rest of the
|
|
1034
|
+
* the duplicated connections; once the HTTP server has stopped, the flow
|
|
1035
|
+
* producer, the queues, and finally the Queue-role connection. Every step
|
|
1036
|
+
* swallows its own errors so a single failure never aborts the rest of the
|
|
1037
|
+
* sequence.
|
|
1038
|
+
*
|
|
1039
|
+
* Why two hooks: NestJS runs `onModuleDestroy` before it stops the HTTP server,
|
|
1040
|
+
* so a request that is still being served can enqueue a job after that hook has
|
|
1041
|
+
* returned. The producer side (queues, flow producer, Queue-role connection)
|
|
1042
|
+
* therefore waits for `onApplicationShutdown`, while consumption stops early.
|
|
1034
1043
|
*
|
|
1035
1044
|
* Connection ownership: in **Mode B** the library-owned Queue-role client is
|
|
1036
1045
|
* quit by the connection resolver; in **Mode A** that step is a no-op and only
|
|
1037
1046
|
* the duplicated worker/queue-events connections the library created are closed
|
|
1038
1047
|
* — the consumer's shared client is never touched.
|
|
1039
1048
|
*/
|
|
1040
|
-
declare class QueueLifecycle implements OnModuleDestroy {
|
|
1049
|
+
declare class QueueLifecycle implements OnModuleDestroy, OnApplicationShutdown {
|
|
1041
1050
|
private readonly workers;
|
|
1042
1051
|
private readonly events;
|
|
1043
1052
|
private readonly queues;
|
|
@@ -1045,12 +1054,22 @@ declare class QueueLifecycle implements OnModuleDestroy {
|
|
|
1045
1054
|
private readonly connection;
|
|
1046
1055
|
private readonly resolved;
|
|
1047
1056
|
private readonly logger;
|
|
1057
|
+
private startedAt;
|
|
1058
|
+
private forcedWorkers;
|
|
1048
1059
|
constructor(workers: WorkerRegistry, events: QueueEventsRegistry, queues: QueueService, flow: FlowService, connection: ConnectionResolver, resolved: ResolvedQueueOptions);
|
|
1049
1060
|
/**
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1061
|
+
* Stop consumption: drain the workers within the bounded budget, then close
|
|
1062
|
+
* queue-events and the connections the library opened for them. Called by
|
|
1063
|
+
* NestJS when the application context closes (e.g. on `SIGTERM` with shutdown
|
|
1064
|
+
* hooks enabled), before the HTTP server stops.
|
|
1052
1065
|
*/
|
|
1053
1066
|
onModuleDestroy(): Promise<void>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Release the producer side once the HTTP server has stopped: the optional
|
|
1069
|
+
* queue drain, the flow producer, the cached queues, and the Queue-role
|
|
1070
|
+
* connection, then log the total shutdown time.
|
|
1071
|
+
*/
|
|
1072
|
+
onApplicationShutdown(): Promise<void>;
|
|
1054
1073
|
/**
|
|
1055
1074
|
* Close every worker with a bounded drain, force-closing any that exceed the
|
|
1056
1075
|
* budget. Returns the number of workers that had to be force-closed.
|