@fluojs/queue 1.0.0-beta.2 → 1.0.0-beta.3
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 +13 -6
- package/README.md +11 -6
- package/dist/dead-letter-manager.d.ts +9 -0
- package/dist/dead-letter-manager.d.ts.map +1 -1
- package/dist/dead-letter-manager.js +12 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +2 -2
- package/dist/helpers.d.ts +52 -0
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +61 -0
- package/dist/metadata.d.ts +15 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +18 -0
- package/dist/worker-discovery.d.ts +8 -0
- package/dist/worker-discovery.d.ts.map +1 -1
- package/dist/worker-discovery.js +8 -0
- package/package.json +4 -4
package/README.ko.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<p><a href="./README.md"><kbd>English</kbd></a> <strong><kbd>한국어</kbd></strong></p>
|
|
4
4
|
|
|
5
|
-
fluo를 위한 Redis 기반 분산 작업 처리 패키지입니다. 데코레이터 기반의 워커 탐색,
|
|
5
|
+
fluo를 위한 Redis 기반 분산 작업 처리 패키지입니다. 데코레이터 기반의 워커 탐색, JSON-safe 작업 직렬화, 그리고 수명 주기 관리 기능을 제공합니다.
|
|
6
6
|
|
|
7
7
|
## 목차
|
|
8
8
|
|
|
@@ -52,9 +52,7 @@ export class OrderWorker {
|
|
|
52
52
|
|
|
53
53
|
`QueueModule`을 등록하고 `QueueLifecycleService`를 주입받아 작업을 큐에 추가합니다.
|
|
54
54
|
|
|
55
|
-
`QueueModule.forRoot(...)`는 큐 등록을 위한 지원되는 루트 엔트리포인트입니다.
|
|
56
|
-
|
|
57
|
-
큐 등록은 `QueueModule.forRoot(...)`로 구성합니다.
|
|
55
|
+
`QueueModule.forRoot(...)`는 애플리케이션 수준 큐 등록을 위한 지원되는 루트 엔트리포인트입니다.
|
|
58
56
|
|
|
59
57
|
```typescript
|
|
60
58
|
import { Module, Inject } from '@fluojs/core';
|
|
@@ -105,10 +103,12 @@ QueueModule.forRoot({ clientName: 'jobs' })
|
|
|
105
103
|
|
|
106
104
|
### 데드 레터 처리 (Dead-Letter Handling)
|
|
107
105
|
|
|
108
|
-
모든
|
|
106
|
+
워커가 모든 재시도를 소진하면 Queue는 Redis의 데드 레터 리스트(`fluo:queue:dead-letter:<jobName>`)에 레코드를 append하여, 나중에 수동으로 확인하거나 복구할 수 있게 합니다. BullMQ job 자체를 이동시키는 것은 아닙니다.
|
|
109
107
|
|
|
110
108
|
`QueueModule.forRoot()`는 기본적으로 작업별 최근 데드 레터 엔트리 `1_000`개만 유지합니다. 무제한 보관이 꼭 필요하면 `defaultDeadLetterMaxEntries: false`로 opt-out 하고, 더 엄격한 운영 예산이 필요하면 더 작은 양의 정수를 지정하세요.
|
|
111
109
|
|
|
110
|
+
Job은 JSON으로 직렬화 가능한 plain object여야 합니다. Queue는 enqueue 전에 job payload를 직렬화하고, worker 측에서 job prototype을 다시 입힙니다.
|
|
111
|
+
|
|
112
112
|
저수준 provider 조합을 루트 barrel API의 일부가 아니라 내부 구현 세부사항으로 취급해야 합니다. 저수준 provider helper는 문서화된 루트 barrel 계약에 포함되지 않습니다.
|
|
113
113
|
|
|
114
114
|
## 공개 API 개요
|
|
@@ -118,13 +118,19 @@ QueueModule.forRoot({ clientName: 'jobs' })
|
|
|
118
118
|
- `QueueModule.forRoot(options)`: 애플리케이션 수준 큐 등록을 구성합니다.
|
|
119
119
|
- `QueueLifecycleService`: 작업을 큐에 추가(`enqueue(job)`)하기 위한 기본 서비스입니다.
|
|
120
120
|
- `@QueueWorker(JobClass, options?)`: 특정 작업을 처리할 핸들러를 지정하는 데코레이터입니다.
|
|
121
|
+
- `QUEUE`: queue facade를 위한 호환성 주입 토큰입니다.
|
|
122
|
+
- `createQueuePlatformStatusSnapshot(...)`: lifecycle/readiness diagnostics를 위한 status snapshot helper입니다.
|
|
121
123
|
|
|
122
124
|
|
|
123
125
|
### 타입
|
|
124
|
-
- `QueueModuleOptions`: 전역 큐 설정(clientName, 기본 시도 횟수, 동시성, 전송률
|
|
126
|
+
- `QueueModuleOptions`: 전역 큐 설정(clientName, 기본 시도 횟수, `defaultBackoff`, 동시성, 전송률 제한, dead-letter retention 등)을 위한 타입입니다.
|
|
125
127
|
- `QueueWorkerOptions`: 개별 작업 설정(시도 횟수, 백오프, 동시성, jobName, 전송률 제한 등)을 위한 타입입니다.
|
|
126
128
|
- `QueueBackoffOptions`: 재시도 백오프 설정(`type`, `delayMs`)을 위한 타입입니다.
|
|
127
129
|
|
|
130
|
+
`QueueModuleOptions`에는 `defaultDeadLetterMaxEntries` 같은 dead-letter retention 설정도 포함됩니다.
|
|
131
|
+
|
|
132
|
+
singleton `@QueueWorker()` provider/controller만 등록됩니다. request/transient worker는 discovery 중 건너뜁니다.
|
|
133
|
+
|
|
128
134
|
## 관련 패키지
|
|
129
135
|
|
|
130
136
|
- `@fluojs/redis`: 작업 데이터 저장을 위한 필수 백엔드 패키지입니다.
|
|
@@ -134,3 +140,4 @@ QueueModule.forRoot({ clientName: 'jobs' })
|
|
|
134
140
|
|
|
135
141
|
- `packages/queue/src/module.test.ts`: 워커 탐색 및 작업 추가 테스트 예제.
|
|
136
142
|
- `packages/queue/src/public-surface.test.ts`: 공개 API 계약 검증 예제.
|
|
143
|
+
- `packages/queue/src/status.test.ts`: Queue lifecycle status snapshot 테스트 예제.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<p><strong><kbd>English</kbd></strong> <a href="./README.ko.md"><kbd>한국어</kbd></a></p>
|
|
4
4
|
|
|
5
|
-
Redis-backed distributed job processing for fluo. It features decorator-based worker discovery,
|
|
5
|
+
Redis-backed distributed job processing for fluo. It features decorator-based worker discovery, JSON-safe job serialization, and lifecycle-managed execution.
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
@@ -52,9 +52,7 @@ export class OrderWorker {
|
|
|
52
52
|
|
|
53
53
|
Import `QueueModule` and inject `QueueLifecycleService` to enqueue jobs.
|
|
54
54
|
|
|
55
|
-
`QueueModule.forRoot(...)` is the supported root entrypoint for queue registration.
|
|
56
|
-
|
|
57
|
-
Use `QueueModule.forRoot(...)` for application-level queue registration.
|
|
55
|
+
`QueueModule.forRoot(...)` is the supported root entrypoint for application-level queue registration.
|
|
58
56
|
|
|
59
57
|
```typescript
|
|
60
58
|
import { Module, Inject } from '@fluojs/core';
|
|
@@ -105,10 +103,12 @@ Workers can be configured with a maximum number of attempts and backoff strategi
|
|
|
105
103
|
|
|
106
104
|
### Dead-Letter Handling
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
When a worker exhausts its retry attempts, Queue appends a dead-letter record to Redis (`fluo:queue:dead-letter:<jobName>`) for manual inspection or recovery. Queue does not move the BullMQ job itself.
|
|
109
107
|
|
|
110
108
|
`QueueModule.forRoot()` keeps the most recent `1_000` dead-letter entries per job by default. Set `defaultDeadLetterMaxEntries: false` to opt out, or provide a smaller positive number when operators need a tighter retention budget.
|
|
111
109
|
|
|
110
|
+
Jobs must be JSON-serializable plain objects. Queue serializes the job payload before enqueueing and rehydrates the job prototype on the worker side.
|
|
111
|
+
|
|
112
112
|
Treat low-level provider assembly as an internal implementation detail: low-level provider helpers are not part of the documented root-barrel contract.
|
|
113
113
|
|
|
114
114
|
## Public API Overview
|
|
@@ -118,15 +118,19 @@ Treat low-level provider assembly as an internal implementation detail: low-leve
|
|
|
118
118
|
- `QueueModule.forRoot(options)`: Registers queue support for an application module.
|
|
119
119
|
- `QueueLifecycleService`: Primary service for enqueuing jobs (`enqueue(job)`).
|
|
120
120
|
- `@QueueWorker(JobClass, options?)`: Decorator to mark a class as a job handler.
|
|
121
|
+
- `QUEUE`: Compatibility injection token for the queue facade.
|
|
122
|
+
- `createQueuePlatformStatusSnapshot(...)`: Status snapshot helper for lifecycle/readiness diagnostics.
|
|
121
123
|
|
|
122
124
|
|
|
123
125
|
### Types
|
|
124
|
-
- `QueueModuleOptions`: Global queue settings (clientName, default attempts, concurrency, rate limiting).
|
|
126
|
+
- `QueueModuleOptions`: Global queue settings (clientName, default attempts, `defaultBackoff`, concurrency, rate limiting, dead-letter retention).
|
|
125
127
|
- `QueueWorkerOptions`: Per-job settings (attempts, backoff, concurrency, jobName, rate limiting).
|
|
126
128
|
- `QueueBackoffOptions`: Retry backoff settings (`type`, `delayMs`).
|
|
127
129
|
|
|
128
130
|
`QueueModuleOptions` also includes dead-letter retention controls such as `defaultDeadLetterMaxEntries`.
|
|
129
131
|
|
|
132
|
+
Only singleton `@QueueWorker()` providers/controllers are registered. Request/transient workers are skipped during discovery.
|
|
133
|
+
|
|
130
134
|
## Related Packages
|
|
131
135
|
|
|
132
136
|
- `@fluojs/redis`: Required as the backing store for job persistence.
|
|
@@ -136,3 +140,4 @@ Treat low-level provider assembly as an internal implementation detail: low-leve
|
|
|
136
140
|
|
|
137
141
|
- `packages/queue/src/module.test.ts`: Worker discovery and enqueueing tests.
|
|
138
142
|
- `packages/queue/src/public-surface.test.ts`: Public API contract verification.
|
|
143
|
+
- `packages/queue/src/status.test.ts`: Queue lifecycle status snapshot tests.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ApplicationLogger } from '@fluojs/runtime';
|
|
2
2
|
import type { NormalizedQueueModuleOptions, QueueWorkerDescriptor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Describes the queue dead letter job contract.
|
|
5
|
+
*/
|
|
3
6
|
export interface QueueDeadLetterJob {
|
|
4
7
|
attemptsMade: number;
|
|
5
8
|
data: unknown;
|
|
@@ -9,10 +12,16 @@ export interface QueueDeadLetterJob {
|
|
|
9
12
|
attempts?: number;
|
|
10
13
|
};
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Describes the queue redis dead letter client contract.
|
|
17
|
+
*/
|
|
12
18
|
export interface QueueRedisDeadLetterClient {
|
|
13
19
|
ltrim(key: string, start: number, stop: number): Promise<unknown>;
|
|
14
20
|
rpush(key: string, value: string): Promise<unknown>;
|
|
15
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents the queue dead letter manager.
|
|
24
|
+
*/
|
|
16
25
|
export declare class QueueDeadLetterManager {
|
|
17
26
|
private readonly options;
|
|
18
27
|
private readonly logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dead-letter-manager.d.ts","sourceRoot":"","sources":["../src/dead-letter-manager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,KAAK,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAMtF,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD;AAED,qBAAa,sBAAsB;IAI/B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc;IALjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;gBAGvC,OAAO,EAAE,4BAA4B,EACrC,MAAM,EAAE,iBAAiB,EACzB,cAAc,EAAE,MAAM,0BAA0B;IAGnE,IAAI,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AM,0BAA0B;IAGnE,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,EAAE,GAAG,EAAE,kBAAkB,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAY1G,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;YAmB3B,sBAAsB;IA+BpC,OAAO,CAAC,iBAAiB;CAQ1B"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { cloneWithFallback } from '@fluojs/core/internal';
|
|
2
2
|
import { normalizePositiveInteger, withTimeout } from './helpers.js';
|
|
3
3
|
const DEAD_LETTER_DRAIN_TIMEOUT_MS = 5_000;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Describes the queue dead letter job contract.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Describes the queue redis dead letter client contract.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the queue dead letter manager.
|
|
15
|
+
*/
|
|
4
16
|
export class QueueDeadLetterManager {
|
|
5
17
|
pendingWrites = new Set();
|
|
6
18
|
constructor(options, logger, getRedisClient) {
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAuB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExF,KAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAuB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExF,KAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;AAiBpF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,kBAAuB,GAAG,kBAAkB,CAWvG"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ensureMetadataSymbol } from '@fluojs/core/internal';
|
|
2
2
|
import { queueWorkerMetadataSymbol } from './metadata.js';
|
|
3
|
+
ensureMetadataSymbol();
|
|
3
4
|
function getStandardMetadataBag(metadata) {
|
|
4
|
-
void metadataSymbol;
|
|
5
5
|
return metadata;
|
|
6
6
|
}
|
|
7
7
|
function defineStandardQueueWorkerMetadata(metadata, workerMetadata) {
|
package/dist/helpers.d.ts
CHANGED
|
@@ -2,21 +2,73 @@ import { type Token } from '@fluojs/core';
|
|
|
2
2
|
import type { Provider } from '@fluojs/di';
|
|
3
3
|
import type { CompiledModule } from '@fluojs/runtime';
|
|
4
4
|
import type { QueueRateLimiterOptions } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Defines the scope type.
|
|
7
|
+
*/
|
|
5
8
|
export type Scope = 'request' | 'singleton' | 'transient';
|
|
9
|
+
/**
|
|
10
|
+
* Describes the discovery candidate contract.
|
|
11
|
+
*/
|
|
6
12
|
export interface DiscoveryCandidate {
|
|
7
13
|
moduleName: string;
|
|
8
14
|
scope: Scope;
|
|
9
15
|
targetType: Function;
|
|
10
16
|
token: Token;
|
|
11
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Scope from provider.
|
|
20
|
+
*
|
|
21
|
+
* @param provider The provider.
|
|
22
|
+
* @returns The scope from provider result.
|
|
23
|
+
*/
|
|
12
24
|
export declare function scopeFromProvider(provider: Provider): Scope;
|
|
25
|
+
/**
|
|
26
|
+
* Is class provider.
|
|
27
|
+
*
|
|
28
|
+
* @param provider The provider.
|
|
29
|
+
* @returns The is class provider result.
|
|
30
|
+
*/
|
|
13
31
|
export declare function isClassProvider(provider: Provider): provider is Extract<Provider, {
|
|
14
32
|
provide: Token;
|
|
15
33
|
useClass: Function;
|
|
16
34
|
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Collect discovery candidates.
|
|
37
|
+
*
|
|
38
|
+
* @param compiledModules The compiled modules.
|
|
39
|
+
* @returns The collect discovery candidates result.
|
|
40
|
+
*/
|
|
17
41
|
export declare function collectDiscoveryCandidates(compiledModules: readonly CompiledModule[]): DiscoveryCandidate[];
|
|
42
|
+
/**
|
|
43
|
+
* Normalize positive integer.
|
|
44
|
+
*
|
|
45
|
+
* @param value The value.
|
|
46
|
+
* @param fallback The fallback.
|
|
47
|
+
* @returns The normalize positive integer result.
|
|
48
|
+
*/
|
|
18
49
|
export declare function normalizePositiveInteger(value: number | undefined, fallback: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Normalize positive integer or false.
|
|
52
|
+
*
|
|
53
|
+
* @param value The value.
|
|
54
|
+
* @param fallback The fallback.
|
|
55
|
+
* @returns The normalize positive integer or false result.
|
|
56
|
+
*/
|
|
19
57
|
export declare function normalizePositiveIntegerOrFalse(value: number | false | undefined, fallback: number | false): number | false;
|
|
58
|
+
/**
|
|
59
|
+
* Normalize rate limiter.
|
|
60
|
+
*
|
|
61
|
+
* @param rateLimiter The rate limiter.
|
|
62
|
+
* @returns The normalize rate limiter result.
|
|
63
|
+
*/
|
|
20
64
|
export declare function normalizeRateLimiter(rateLimiter: QueueRateLimiterOptions | undefined): QueueRateLimiterOptions | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* With timeout.
|
|
67
|
+
*
|
|
68
|
+
* @param promise The promise.
|
|
69
|
+
* @param timeoutMs The timeout ms.
|
|
70
|
+
* @param timeoutErrorFactory The timeout error factory.
|
|
71
|
+
* @returns The with timeout result.
|
|
72
|
+
*/
|
|
21
73
|
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutErrorFactory: () =>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EAAE,MAAM,GAAG,MAAM,CAY5F;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,EACjC,QAAQ,EAAE,MAAM,GAAG,KAAK,GACvB,MAAM,GAAG,KAAK,CAgBhB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,uBAAuB,GAAG,SAAS,GAAG,uBAAuB,GAAG,SAAS,CAS1H;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,MAAM,KAAK,GAC/B,OAAO,CAAC,CAAC,CAAC,CAeZ"}
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { getClassDiMetadata } from '@fluojs/core/internal';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defines the scope type.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Describes the discovery candidate contract.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Scope from provider.
|
|
13
|
+
*
|
|
14
|
+
* @param provider The provider.
|
|
15
|
+
* @returns The scope from provider result.
|
|
16
|
+
*/
|
|
2
17
|
export function scopeFromProvider(provider) {
|
|
3
18
|
if (typeof provider === 'function') {
|
|
4
19
|
return getClassDiMetadata(provider)?.scope ?? 'singleton';
|
|
@@ -8,9 +23,23 @@ export function scopeFromProvider(provider) {
|
|
|
8
23
|
}
|
|
9
24
|
return 'scope' in provider ? provider.scope ?? 'singleton' : 'singleton';
|
|
10
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Is class provider.
|
|
29
|
+
*
|
|
30
|
+
* @param provider The provider.
|
|
31
|
+
* @returns The is class provider result.
|
|
32
|
+
*/
|
|
11
33
|
export function isClassProvider(provider) {
|
|
12
34
|
return typeof provider === 'object' && provider !== null && 'useClass' in provider;
|
|
13
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Collect discovery candidates.
|
|
39
|
+
*
|
|
40
|
+
* @param compiledModules The compiled modules.
|
|
41
|
+
* @returns The collect discovery candidates result.
|
|
42
|
+
*/
|
|
14
43
|
export function collectDiscoveryCandidates(compiledModules) {
|
|
15
44
|
const candidates = [];
|
|
16
45
|
for (const compiledModule of compiledModules) {
|
|
@@ -44,6 +73,14 @@ export function collectDiscoveryCandidates(compiledModules) {
|
|
|
44
73
|
}
|
|
45
74
|
return candidates;
|
|
46
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Normalize positive integer.
|
|
79
|
+
*
|
|
80
|
+
* @param value The value.
|
|
81
|
+
* @param fallback The fallback.
|
|
82
|
+
* @returns The normalize positive integer result.
|
|
83
|
+
*/
|
|
47
84
|
export function normalizePositiveInteger(value, fallback) {
|
|
48
85
|
if (value === undefined || !Number.isFinite(value)) {
|
|
49
86
|
return fallback;
|
|
@@ -54,6 +91,14 @@ export function normalizePositiveInteger(value, fallback) {
|
|
|
54
91
|
}
|
|
55
92
|
return normalized;
|
|
56
93
|
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Normalize positive integer or false.
|
|
97
|
+
*
|
|
98
|
+
* @param value The value.
|
|
99
|
+
* @param fallback The fallback.
|
|
100
|
+
* @returns The normalize positive integer or false result.
|
|
101
|
+
*/
|
|
57
102
|
export function normalizePositiveIntegerOrFalse(value, fallback) {
|
|
58
103
|
if (value === false) {
|
|
59
104
|
return false;
|
|
@@ -67,6 +112,13 @@ export function normalizePositiveIntegerOrFalse(value, fallback) {
|
|
|
67
112
|
}
|
|
68
113
|
return normalized;
|
|
69
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Normalize rate limiter.
|
|
118
|
+
*
|
|
119
|
+
* @param rateLimiter The rate limiter.
|
|
120
|
+
* @returns The normalize rate limiter result.
|
|
121
|
+
*/
|
|
70
122
|
export function normalizeRateLimiter(rateLimiter) {
|
|
71
123
|
if (!rateLimiter) {
|
|
72
124
|
return undefined;
|
|
@@ -76,6 +128,15 @@ export function normalizeRateLimiter(rateLimiter) {
|
|
|
76
128
|
max: normalizePositiveInteger(rateLimiter.max, 1)
|
|
77
129
|
};
|
|
78
130
|
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* With timeout.
|
|
134
|
+
*
|
|
135
|
+
* @param promise The promise.
|
|
136
|
+
* @param timeoutMs The timeout ms.
|
|
137
|
+
* @param timeoutErrorFactory The timeout error factory.
|
|
138
|
+
* @returns The with timeout result.
|
|
139
|
+
*/
|
|
79
140
|
export async function withTimeout(promise, timeoutMs, timeoutErrorFactory) {
|
|
80
141
|
let timeoutId;
|
|
81
142
|
const timeoutPromise = new Promise((_, reject) => {
|
package/dist/metadata.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { QueueWorkerMetadata } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Define queue worker metadata.
|
|
4
|
+
*
|
|
5
|
+
* @param target The target.
|
|
6
|
+
* @param metadata The metadata.
|
|
7
|
+
*/
|
|
2
8
|
export declare function defineQueueWorkerMetadata(target: Function, metadata: QueueWorkerMetadata): void;
|
|
9
|
+
/**
|
|
10
|
+
* Get queue worker metadata.
|
|
11
|
+
*
|
|
12
|
+
* @param target The target.
|
|
13
|
+
* @returns The get queue worker metadata result.
|
|
14
|
+
*/
|
|
3
15
|
export declare function getQueueWorkerMetadata(target: Function): QueueWorkerMetadata | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Provides the queue worker metadata symbol value.
|
|
18
|
+
*/
|
|
4
19
|
export declare const queueWorkerMetadataSymbol: symbol;
|
|
5
20
|
//# sourceMappingURL=metadata.d.ts.map
|
package/dist/metadata.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAkBtD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAE/F;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,GAAG,mBAAmB,GAAG,SAAS,CASxF;AAED,eAAO,MAAM,yBAAyB,QAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAkBtD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,GAAG,mBAAmB,GAAG,SAAS,CASxF;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAiC,CAAC"}
|
package/dist/metadata.js
CHANGED
|
@@ -13,9 +13,23 @@ function cloneQueueWorkerMetadata(metadata) {
|
|
|
13
13
|
function getStandardQueueWorkerMetadata(target) {
|
|
14
14
|
return getStandardMetadataBag(target)?.[standardQueueWorkerMetadataKey];
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Define queue worker metadata.
|
|
19
|
+
*
|
|
20
|
+
* @param target The target.
|
|
21
|
+
* @param metadata The metadata.
|
|
22
|
+
*/
|
|
16
23
|
export function defineQueueWorkerMetadata(target, metadata) {
|
|
17
24
|
queueWorkerMetadataStore.set(target, cloneQueueWorkerMetadata(metadata));
|
|
18
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get queue worker metadata.
|
|
29
|
+
*
|
|
30
|
+
* @param target The target.
|
|
31
|
+
* @returns The get queue worker metadata result.
|
|
32
|
+
*/
|
|
19
33
|
export function getQueueWorkerMetadata(target) {
|
|
20
34
|
const stored = queueWorkerMetadataStore.get(target);
|
|
21
35
|
const standard = getStandardQueueWorkerMetadata(target);
|
|
@@ -24,4 +38,8 @@ export function getQueueWorkerMetadata(target) {
|
|
|
24
38
|
}
|
|
25
39
|
return cloneQueueWorkerMetadata(stored ?? standard);
|
|
26
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Provides the queue worker metadata symbol value.
|
|
44
|
+
*/
|
|
27
45
|
export const queueWorkerMetadataSymbol = standardQueueWorkerMetadataKey;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { ApplicationLogger, CompiledModule } from '@fluojs/runtime';
|
|
2
2
|
import type { NormalizedQueueModuleOptions, QueueJobType, QueueWorkerDescriptor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Discover queue worker descriptors.
|
|
5
|
+
*
|
|
6
|
+
* @param compiledModules The compiled modules.
|
|
7
|
+
* @param options The options.
|
|
8
|
+
* @param logger The logger.
|
|
9
|
+
* @returns The discover queue worker descriptors result.
|
|
10
|
+
*/
|
|
3
11
|
export declare function discoverQueueWorkerDescriptors(compiledModules: readonly CompiledModule[], options: NormalizedQueueModuleOptions, logger: ApplicationLogger): Map<QueueJobType, QueueWorkerDescriptor>;
|
|
4
12
|
//# 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;AAIzE,OAAO,KAAK,EAAE,4BAA4B,EAAE,YAAY,EAAE,qBAAqB,EAAuB,MAAM,YAAY,CAAC;AAEzH,wBAAgB,8BAA8B,CAC5C,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,OAAO,EAAE,4BAA4B,EACrC,MAAM,EAAE,iBAAiB,GACxB,GAAG,CAAC,YAAY,EAAE,qBAAqB,CAAC,CA4C1C"}
|
|
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;AAIzE,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,GACxB,GAAG,CAAC,YAAY,EAAE,qBAAqB,CAAC,CA4C1C"}
|
package/dist/worker-discovery.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { getQueueWorkerMetadata } from './metadata.js';
|
|
2
2
|
import { collectDiscoveryCandidates, normalizePositiveInteger, normalizeRateLimiter } from './helpers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Discover queue worker descriptors.
|
|
5
|
+
*
|
|
6
|
+
* @param compiledModules The compiled modules.
|
|
7
|
+
* @param options The options.
|
|
8
|
+
* @param logger The logger.
|
|
9
|
+
* @returns The discover queue worker descriptors result.
|
|
10
|
+
*/
|
|
3
11
|
export function discoverQueueWorkerDescriptors(compiledModules, options, logger) {
|
|
4
12
|
const descriptorsByJobType = new Map();
|
|
5
13
|
const seenJobNames = new Set();
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"redis",
|
|
11
11
|
"dlq"
|
|
12
12
|
],
|
|
13
|
-
"version": "1.0.0-beta.
|
|
13
|
+
"version": "1.0.0-beta.3",
|
|
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.0-beta.
|
|
42
|
-
"@fluojs/di": "^1.0.0-beta.
|
|
41
|
+
"@fluojs/core": "^1.0.0-beta.4",
|
|
42
|
+
"@fluojs/di": "^1.0.0-beta.6",
|
|
43
43
|
"@fluojs/redis": "^1.0.0-beta.2",
|
|
44
|
-
"@fluojs/runtime": "^1.0.0-beta.
|
|
44
|
+
"@fluojs/runtime": "^1.0.0-beta.11"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"vitest": "^3.2.4"
|