@fluojs/queue 1.0.1 → 2.0.0
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.ko.md +70 -8
- package/README.md +70 -8
- package/dist/dead-letter-manager.d.ts +10 -1
- package/dist/dead-letter-manager.d.ts.map +1 -1
- package/dist/dead-letter-manager.js +62 -0
- package/dist/helpers.d.ts +3 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +6 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/module.d.ts +2 -2
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +88 -14
- package/dist/service.d.ts +50 -5
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +182 -44
- package/dist/status.d.ts +3 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +33 -0
- package/dist/tokens.d.ts +55 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +111 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker-discovery.d.ts +2 -1
- package/dist/worker-discovery.d.ts.map +1 -1
- package/dist/worker-discovery.js +2 -2
- package/package.json +5 -5
package/dist/status.js
CHANGED
|
@@ -5,7 +5,22 @@
|
|
|
5
5
|
/** Queue-specific platform snapshot returned to health and readiness integrations. */
|
|
6
6
|
|
|
7
7
|
function createReadiness(input) {
|
|
8
|
+
const workerStartFailures = input.workerStartFailures ?? 0;
|
|
9
|
+
if (input.lifecycleState === 'failed' || workerStartFailures > 0) {
|
|
10
|
+
return {
|
|
11
|
+
critical: true,
|
|
12
|
+
reason: 'Queue worker startup failed.',
|
|
13
|
+
status: 'not-ready'
|
|
14
|
+
};
|
|
15
|
+
}
|
|
8
16
|
if (input.lifecycleState === 'started') {
|
|
17
|
+
if (input.workersReady < input.workersDiscovered) {
|
|
18
|
+
return {
|
|
19
|
+
critical: true,
|
|
20
|
+
reason: 'Queue workers are waiting for BullMQ processors to start.',
|
|
21
|
+
status: 'degraded'
|
|
22
|
+
};
|
|
23
|
+
}
|
|
9
24
|
return {
|
|
10
25
|
critical: true,
|
|
11
26
|
status: 'ready'
|
|
@@ -39,6 +54,13 @@ function createReadiness(input) {
|
|
|
39
54
|
};
|
|
40
55
|
}
|
|
41
56
|
function createHealth(input) {
|
|
57
|
+
const workerStartFailures = input.workerStartFailures ?? 0;
|
|
58
|
+
if (input.lifecycleState === 'failed' || workerStartFailures > 0) {
|
|
59
|
+
return {
|
|
60
|
+
reason: 'Queue worker startup failed.',
|
|
61
|
+
status: 'unhealthy'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
42
64
|
if (input.lifecycleState === 'stopped') {
|
|
43
65
|
return {
|
|
44
66
|
reason: 'Queue workers are stopped.',
|
|
@@ -57,6 +79,12 @@ function createHealth(input) {
|
|
|
57
79
|
status: 'degraded'
|
|
58
80
|
};
|
|
59
81
|
}
|
|
82
|
+
if (input.lifecycleState === 'started' && input.workersReady < input.workersDiscovered) {
|
|
83
|
+
return {
|
|
84
|
+
reason: 'Queue workers are waiting for BullMQ processors to start.',
|
|
85
|
+
status: 'degraded'
|
|
86
|
+
};
|
|
87
|
+
}
|
|
60
88
|
if (input.lifecycleState === 'started' && input.pendingDeadLetterWrites > 0) {
|
|
61
89
|
return {
|
|
62
90
|
reason: 'Queue dead-letter writes are still pending.',
|
|
@@ -81,13 +109,18 @@ function createHealth(input) {
|
|
|
81
109
|
* @returns Readiness, health, ownership, and queue detail fields.
|
|
82
110
|
*/
|
|
83
111
|
export function createQueuePlatformStatusSnapshot(input) {
|
|
112
|
+
const workerStartFailures = input.workerStartFailures ?? 0;
|
|
84
113
|
return {
|
|
85
114
|
details: {
|
|
86
115
|
deadLetterDrainTimeoutMs: 5_000,
|
|
87
116
|
dependencies: [input.dependencyId ?? 'redis.default'],
|
|
88
117
|
lifecycleState: input.lifecycleState,
|
|
118
|
+
...(input.lastWorkerStartFailure ? {
|
|
119
|
+
lastWorkerStartFailure: input.lastWorkerStartFailure
|
|
120
|
+
} : {}),
|
|
89
121
|
pendingDeadLetterWrites: input.pendingDeadLetterWrites,
|
|
90
122
|
queuesReady: input.queuesReady,
|
|
123
|
+
workerStartFailures,
|
|
91
124
|
workerShutdownTimeoutMs: input.workerShutdownTimeoutMs,
|
|
92
125
|
workersDiscovered: input.workersDiscovered,
|
|
93
126
|
workersReady: input.workersReady
|
package/dist/tokens.d.ts
CHANGED
|
@@ -1,7 +1,61 @@
|
|
|
1
1
|
import type { Token } from '@fluojs/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModuleType } from '@fluojs/runtime';
|
|
3
|
+
import type { QueueLifecycleService } from './service.js';
|
|
4
|
+
import type { NormalizedQueueModuleOptions, Queue } from './types.js';
|
|
5
|
+
/** Runtime metadata that binds one queue registration to its compiled module graph. */
|
|
6
|
+
export interface QueueModuleContext {
|
|
7
|
+
readonly moduleType: ModuleType;
|
|
8
|
+
readonly scope: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Normalize an optional queue registration scope.
|
|
12
|
+
*
|
|
13
|
+
* @param scope Optional scope name supplied to {@link QueueModule.forRoot}.
|
|
14
|
+
* @returns A trimmed non-empty scope name, or `undefined` for the default registration.
|
|
15
|
+
* @throws When a provided scope contains only whitespace.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeQueueScope(scope?: string): string | undefined;
|
|
18
|
+
/** Queue-owned Redis client token consumed by the default queue registration. */
|
|
19
|
+
export declare const QUEUE_REDIS_CLIENT: Token<unknown>;
|
|
3
20
|
/** Compatibility injection token for the queue facade returned by {@link QueueModule.forRoot}. */
|
|
4
21
|
export declare const QUEUE: Token<Queue>;
|
|
5
22
|
/** Injection token for normalized module defaults consumed by {@link QueueLifecycleService}. */
|
|
6
23
|
export declare const QUEUE_OPTIONS: Token<NormalizedQueueModuleOptions>;
|
|
24
|
+
/** Runtime module-context token consumed by the default queue registration. */
|
|
25
|
+
export declare const QUEUE_MODULE_CONTEXT: Token<QueueModuleContext>;
|
|
26
|
+
/**
|
|
27
|
+
* Return the queue facade token for a default or explicitly scoped registration.
|
|
28
|
+
*
|
|
29
|
+
* @param scope Optional queue registration scope.
|
|
30
|
+
* @returns The compatibility {@link QUEUE} token when omitted, or a stable token for the scoped queue facade.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getQueueToken(scope?: string): Token<Queue>;
|
|
33
|
+
/**
|
|
34
|
+
* Return the lifecycle service token for a default or explicitly scoped queue registration.
|
|
35
|
+
*
|
|
36
|
+
* @param scope Optional queue registration scope.
|
|
37
|
+
* @returns The default lifecycle-service token when omitted, or a stable token for the scoped lifecycle service.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getQueueLifecycleServiceToken(scope?: string): Token<QueueLifecycleService>;
|
|
40
|
+
/**
|
|
41
|
+
* Return the normalized options token for a default or explicitly scoped queue registration.
|
|
42
|
+
*
|
|
43
|
+
* @param scope Optional queue registration scope.
|
|
44
|
+
* @returns The default options token when omitted, or a stable token for scoped normalized options.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getQueueOptionsToken(scope?: string): Token<NormalizedQueueModuleOptions>;
|
|
47
|
+
/**
|
|
48
|
+
* Return the queue-owned Redis client token for a default or explicitly scoped registration.
|
|
49
|
+
*
|
|
50
|
+
* @param scope Optional queue registration scope.
|
|
51
|
+
* @returns The default Redis client token when omitted, or a stable token for the scoped Redis dependency.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getQueueRedisClientToken(scope?: string): Token<unknown>;
|
|
54
|
+
/**
|
|
55
|
+
* Return the module-context token for a default or explicitly scoped queue registration.
|
|
56
|
+
*
|
|
57
|
+
* @param scope Optional queue registration scope.
|
|
58
|
+
* @returns The default module-context token when omitted, or a stable token for scoped queue context.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getQueueModuleContextToken(scope?: string): Token<QueueModuleContext>;
|
|
7
61
|
//# sourceMappingURL=tokens.d.ts.map
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtE,uFAAuF;AACvF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAQD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAYtE;AAcD,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAyC,CAAC;AACxF,kGAAkG;AAClG,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAA4B,CAAC;AAC5D,gGAAgG;AAChG,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,4BAA4B,CAAoC,CAAC;AACnG,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,kBAAkB,CAA2C,CAAC;AAEvG;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAQ1D;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAQ1F;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,4BAA4B,CAAC,CAQxF;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAQvE;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAQpF"}
|
package/dist/tokens.js
CHANGED
|
@@ -1,4 +1,114 @@
|
|
|
1
|
+
/** Runtime metadata that binds one queue registration to its compiled module graph. */
|
|
2
|
+
|
|
3
|
+
const scopedQueueTokens = new Map();
|
|
4
|
+
const scopedQueueLifecycleServiceTokens = new Map();
|
|
5
|
+
const scopedQueueOptionsTokens = new Map();
|
|
6
|
+
const scopedQueueRedisClientTokens = new Map();
|
|
7
|
+
const scopedQueueModuleContextTokens = new Map();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Normalize an optional queue registration scope.
|
|
11
|
+
*
|
|
12
|
+
* @param scope Optional scope name supplied to {@link QueueModule.forRoot}.
|
|
13
|
+
* @returns A trimmed non-empty scope name, or `undefined` for the default registration.
|
|
14
|
+
* @throws When a provided scope contains only whitespace.
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeQueueScope(scope) {
|
|
17
|
+
if (scope === undefined) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const normalized = scope.trim();
|
|
21
|
+
if (normalized.length === 0) {
|
|
22
|
+
throw new Error('Queue scope must be a non-empty string when provided.');
|
|
23
|
+
}
|
|
24
|
+
return normalized;
|
|
25
|
+
}
|
|
26
|
+
function getScopedToken(tokens, scope, description) {
|
|
27
|
+
const existing = tokens.get(scope);
|
|
28
|
+
if (existing) {
|
|
29
|
+
return existing;
|
|
30
|
+
}
|
|
31
|
+
const created = Symbol(`${description}:${scope}`);
|
|
32
|
+
tokens.set(scope, created);
|
|
33
|
+
return created;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Queue-owned Redis client token consumed by the default queue registration. */
|
|
37
|
+
export const QUEUE_REDIS_CLIENT = Symbol.for('fluo.queue.redis-client');
|
|
1
38
|
/** Compatibility injection token for the queue facade returned by {@link QueueModule.forRoot}. */
|
|
2
39
|
export const QUEUE = Symbol.for('fluo.queue');
|
|
3
40
|
/** Injection token for normalized module defaults consumed by {@link QueueLifecycleService}. */
|
|
4
|
-
export const QUEUE_OPTIONS = Symbol.for('fluo.queue.options');
|
|
41
|
+
export const QUEUE_OPTIONS = Symbol.for('fluo.queue.options');
|
|
42
|
+
/** Runtime module-context token consumed by the default queue registration. */
|
|
43
|
+
export const QUEUE_MODULE_CONTEXT = Symbol.for('fluo.queue.module-context');
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Return the queue facade token for a default or explicitly scoped registration.
|
|
47
|
+
*
|
|
48
|
+
* @param scope Optional queue registration scope.
|
|
49
|
+
* @returns The compatibility {@link QUEUE} token when omitted, or a stable token for the scoped queue facade.
|
|
50
|
+
*/
|
|
51
|
+
export function getQueueToken(scope) {
|
|
52
|
+
const normalizedScope = normalizeQueueScope(scope);
|
|
53
|
+
if (normalizedScope === undefined) {
|
|
54
|
+
return QUEUE;
|
|
55
|
+
}
|
|
56
|
+
return getScopedToken(scopedQueueTokens, normalizedScope, 'fluo.queue');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Return the lifecycle service token for a default or explicitly scoped queue registration.
|
|
61
|
+
*
|
|
62
|
+
* @param scope Optional queue registration scope.
|
|
63
|
+
* @returns The default lifecycle-service token when omitted, or a stable token for the scoped lifecycle service.
|
|
64
|
+
*/
|
|
65
|
+
export function getQueueLifecycleServiceToken(scope) {
|
|
66
|
+
const normalizedScope = normalizeQueueScope(scope);
|
|
67
|
+
if (normalizedScope === undefined) {
|
|
68
|
+
return QueueLifecycleServiceToken;
|
|
69
|
+
}
|
|
70
|
+
return getScopedToken(scopedQueueLifecycleServiceTokens, normalizedScope, 'fluo.queue.lifecycle-service');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Return the normalized options token for a default or explicitly scoped queue registration.
|
|
75
|
+
*
|
|
76
|
+
* @param scope Optional queue registration scope.
|
|
77
|
+
* @returns The default options token when omitted, or a stable token for scoped normalized options.
|
|
78
|
+
*/
|
|
79
|
+
export function getQueueOptionsToken(scope) {
|
|
80
|
+
const normalizedScope = normalizeQueueScope(scope);
|
|
81
|
+
if (normalizedScope === undefined) {
|
|
82
|
+
return QUEUE_OPTIONS;
|
|
83
|
+
}
|
|
84
|
+
return getScopedToken(scopedQueueOptionsTokens, normalizedScope, 'fluo.queue.options');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Return the queue-owned Redis client token for a default or explicitly scoped registration.
|
|
89
|
+
*
|
|
90
|
+
* @param scope Optional queue registration scope.
|
|
91
|
+
* @returns The default Redis client token when omitted, or a stable token for the scoped Redis dependency.
|
|
92
|
+
*/
|
|
93
|
+
export function getQueueRedisClientToken(scope) {
|
|
94
|
+
const normalizedScope = normalizeQueueScope(scope);
|
|
95
|
+
if (normalizedScope === undefined) {
|
|
96
|
+
return QUEUE_REDIS_CLIENT;
|
|
97
|
+
}
|
|
98
|
+
return getScopedToken(scopedQueueRedisClientTokens, normalizedScope, 'fluo.queue.redis-client');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Return the module-context token for a default or explicitly scoped queue registration.
|
|
103
|
+
*
|
|
104
|
+
* @param scope Optional queue registration scope.
|
|
105
|
+
* @returns The default module-context token when omitted, or a stable token for scoped queue context.
|
|
106
|
+
*/
|
|
107
|
+
export function getQueueModuleContextToken(scope) {
|
|
108
|
+
const normalizedScope = normalizeQueueScope(scope);
|
|
109
|
+
if (normalizedScope === undefined) {
|
|
110
|
+
return QUEUE_MODULE_CONTEXT;
|
|
111
|
+
}
|
|
112
|
+
return getScopedToken(scopedQueueModuleContextTokens, normalizedScope, 'fluo.queue.module-context');
|
|
113
|
+
}
|
|
114
|
+
const QueueLifecycleServiceToken = Symbol.for('fluo.queue.lifecycle-service.default');
|
package/dist/types.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface QueueWorkerOptions {
|
|
|
31
31
|
/** Module-wide defaults used when individual workers omit execution settings. */
|
|
32
32
|
export interface QueueModuleOptions {
|
|
33
33
|
clientName?: string;
|
|
34
|
+
/** Unique registration scope for non-global queue modules that need isolated providers. */
|
|
35
|
+
scope?: string;
|
|
34
36
|
/** Whether queue providers should be visible globally. Defaults to `true`. */
|
|
35
37
|
global?: boolean;
|
|
36
38
|
defaultAttempts?: number;
|
|
@@ -44,11 +46,13 @@ export interface QueueModuleOptions {
|
|
|
44
46
|
/** Normalized queue options resolved once during module registration. */
|
|
45
47
|
export interface NormalizedQueueModuleOptions {
|
|
46
48
|
clientName?: string;
|
|
49
|
+
scope?: string;
|
|
47
50
|
defaultAttempts: number;
|
|
48
51
|
defaultBackoff?: QueueBackoffOptions;
|
|
49
52
|
defaultConcurrency: number;
|
|
50
53
|
defaultDeadLetterMaxEntries: number | false;
|
|
51
54
|
defaultRateLimiter?: QueueRateLimiterOptions;
|
|
55
|
+
global: boolean;
|
|
52
56
|
workerShutdownTimeoutMs: number;
|
|
53
57
|
}
|
|
54
58
|
/** Metadata captured by {@link QueueWorker} during decorator evaluation. */
|
|
@@ -68,6 +72,27 @@ export interface QueueWorkerDescriptor {
|
|
|
68
72
|
token: Token;
|
|
69
73
|
workerName: string;
|
|
70
74
|
}
|
|
75
|
+
/** Options for one read-only dead-letter inspection. */
|
|
76
|
+
export interface QueueDeadLetterInspectionOptions {
|
|
77
|
+
/** Maximum number of stored entries to inspect. Defaults to `100` and is capped at `1_000`. */
|
|
78
|
+
readonly limit?: number;
|
|
79
|
+
}
|
|
80
|
+
/** Parsed operator-facing view of one dead-letter record. */
|
|
81
|
+
export interface QueueDeadLetterRecord {
|
|
82
|
+
readonly attemptsMade: number;
|
|
83
|
+
readonly errorMessage: string;
|
|
84
|
+
readonly failedAt: string;
|
|
85
|
+
readonly jobId: string;
|
|
86
|
+
readonly jobName: string;
|
|
87
|
+
readonly payload: unknown;
|
|
88
|
+
}
|
|
89
|
+
/** Result of a bounded dead-letter inspection. */
|
|
90
|
+
export interface QueueDeadLetterInspectionResult {
|
|
91
|
+
/** Number of malformed stored values omitted from the inspected window. */
|
|
92
|
+
readonly malformedRecordCount: number;
|
|
93
|
+
/** Valid records in newest-first order. */
|
|
94
|
+
readonly records: readonly QueueDeadLetterRecord[];
|
|
95
|
+
}
|
|
71
96
|
/** Queue facade exposed to application code and compatibility tokens. */
|
|
72
97
|
export interface Queue {
|
|
73
98
|
/**
|
|
@@ -77,5 +102,13 @@ export interface Queue {
|
|
|
77
102
|
* @returns The BullMQ job id generated for the enqueued payload.
|
|
78
103
|
*/
|
|
79
104
|
enqueue<TJob extends object>(job: TJob): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Reads a bounded snapshot of dead-letter records for one queue job name.
|
|
107
|
+
*
|
|
108
|
+
* @param jobName Queue worker job name whose dead letters should be inspected.
|
|
109
|
+
* @param options Optional bounded inspection settings.
|
|
110
|
+
* @returns Valid records in newest-first order plus the malformed count for the inspected window.
|
|
111
|
+
*/
|
|
112
|
+
inspectDeadLetters(jobName: string, options?: QueueDeadLetterInspectionOptions): Promise<QueueDeadLetterInspectionResult>;
|
|
80
113
|
}
|
|
81
114
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,oFAAoF;AACpF,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,M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ojs/runtime';
|
|
2
|
+
import { type DiscoveryModuleFilter } from './helpers.js';
|
|
2
3
|
import type { NormalizedQueueModuleOptions, QueueJobType, QueueWorkerDescriptor } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Discover queue worker descriptors.
|
|
@@ -8,5 +9,5 @@ import type { NormalizedQueueModuleOptions, QueueJobType, QueueWorkerDescriptor
|
|
|
8
9
|
* @param logger The logger.
|
|
9
10
|
* @returns The discover queue worker descriptors result.
|
|
10
11
|
*/
|
|
11
|
-
export declare function discoverQueueWorkerDescriptors(compiledModules: readonly CompiledModule[], options: NormalizedQueueModuleOptions, logger: ApplicationLogger): Map<QueueJobType, QueueWorkerDescriptor>;
|
|
12
|
+
export declare function discoverQueueWorkerDescriptors(compiledModules: readonly CompiledModule[], options: NormalizedQueueModuleOptions, logger: ApplicationLogger, moduleFilter?: DiscoveryModuleFilter): Map<QueueJobType, QueueWorkerDescriptor>;
|
|
12
13
|
//# sourceMappingURL=worker-discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-discovery.d.ts","sourceRoot":"","sources":["../src/worker-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-discovery.d.ts","sourceRoot":"","sources":["../src/worker-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAA8B,KAAK,qBAAqB,EAAkD,MAAM,cAAc,CAAC;AACtI,OAAO,KAAK,EAAE,4BAA4B,EAAE,YAAY,EAAE,qBAAqB,EAAuB,MAAM,YAAY,CAAC;AAEzH;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,OAAO,EAAE,4BAA4B,EACrC,MAAM,EAAE,iBAAiB,EACzB,YAAY,CAAC,EAAE,qBAAqB,GACnC,GAAG,CAAC,YAAY,EAAE,qBAAqB,CAAC,CA4C1C"}
|
package/dist/worker-discovery.js
CHANGED
|
@@ -8,10 +8,10 @@ import { collectDiscoveryCandidates, normalizePositiveInteger, normalizeRateLimi
|
|
|
8
8
|
* @param logger The logger.
|
|
9
9
|
* @returns The discover queue worker descriptors result.
|
|
10
10
|
*/
|
|
11
|
-
export function discoverQueueWorkerDescriptors(compiledModules, options, logger) {
|
|
11
|
+
export function discoverQueueWorkerDescriptors(compiledModules, options, logger, moduleFilter) {
|
|
12
12
|
const descriptorsByJobType = new Map();
|
|
13
13
|
const seenJobNames = new Set();
|
|
14
|
-
for (const candidate of collectDiscoveryCandidates(compiledModules)) {
|
|
14
|
+
for (const candidate of collectDiscoveryCandidates(compiledModules, moduleFilter)) {
|
|
15
15
|
const metadata = getQueueWorkerMetadata(candidate.targetType);
|
|
16
16
|
if (!metadata) {
|
|
17
17
|
continue;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"redis",
|
|
11
11
|
"dlq"
|
|
12
12
|
],
|
|
13
|
-
"version": "
|
|
13
|
+
"version": "2.0.0",
|
|
14
14
|
"private": false,
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"bullmq": "^5.58.0",
|
|
41
|
-
"@fluojs/core": "^1.0
|
|
42
|
-
"@fluojs/di": "^
|
|
43
|
-
"@fluojs/redis": "^1.0
|
|
44
|
-
"@fluojs/runtime": "^
|
|
41
|
+
"@fluojs/core": "^1.1.0",
|
|
42
|
+
"@fluojs/di": "^2.0.0",
|
|
43
|
+
"@fluojs/redis": "^1.1.0",
|
|
44
|
+
"@fluojs/runtime": "^2.0.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"vitest": "^3.2.4"
|