@nathapp/nestjs-queue 2.1.0-rc.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/CLAUDE.md +106 -0
- package/TODO.md +44 -0
- package/dist/constant/index.d.ts +1 -0
- package/dist/constant/index.js +18 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/queue.constant.d.ts +6 -0
- package/dist/constant/queue.constant.js +10 -0
- package/dist/constant/queue.constant.js.map +1 -0
- package/dist/decorator/index.d.ts +3 -0
- package/dist/decorator/index.js +20 -0
- package/dist/decorator/index.js.map +1 -0
- package/dist/decorator/on-queue-event.decorator.d.ts +6 -0
- package/dist/decorator/on-queue-event.decorator.js +18 -0
- package/dist/decorator/on-queue-event.decorator.js.map +1 -0
- package/dist/decorator/process.decorator.d.ts +5 -0
- package/dist/decorator/process.decorator.js +18 -0
- package/dist/decorator/process.decorator.js.map +1 -0
- package/dist/decorator/processor.decorator.d.ts +5 -0
- package/dist/decorator/processor.decorator.js +12 -0
- package/dist/decorator/processor.decorator.js.map +1 -0
- package/dist/enum/index.d.ts +3 -0
- package/dist/enum/index.js +20 -0
- package/dist/enum/index.js.map +1 -0
- package/dist/enum/job-status.enum.d.ts +8 -0
- package/dist/enum/job-status.enum.js +13 -0
- package/dist/enum/job-status.enum.js.map +1 -0
- package/dist/enum/provider.enum.d.ts +7 -0
- package/dist/enum/provider.enum.js +12 -0
- package/dist/enum/provider.enum.js.map +1 -0
- package/dist/enum/queue-event.enum.d.ts +11 -0
- package/dist/enum/queue-event.enum.js +16 -0
- package/dist/enum/queue-event.enum.js.map +1 -0
- package/dist/explorer/index.d.ts +1 -0
- package/dist/explorer/index.js +18 -0
- package/dist/explorer/index.js.map +1 -0
- package/dist/explorer/processor.explorer.d.ts +25 -0
- package/dist/explorer/processor.explorer.js +241 -0
- package/dist/explorer/processor.explorer.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/interface/circuit-breaker.interface.d.ts +21 -0
- package/dist/interface/circuit-breaker.interface.js +10 -0
- package/dist/interface/circuit-breaker.interface.js.map +1 -0
- package/dist/interface/health.interface.d.ts +12 -0
- package/dist/interface/health.interface.js +3 -0
- package/dist/interface/health.interface.js.map +1 -0
- package/dist/interface/idempotency-store.interface.d.ts +14 -0
- package/dist/interface/idempotency-store.interface.js +3 -0
- package/dist/interface/idempotency-store.interface.js.map +1 -0
- package/dist/interface/index.d.ts +5 -0
- package/dist/interface/index.js +22 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/job.interface.d.ts +56 -0
- package/dist/interface/job.interface.js +3 -0
- package/dist/interface/job.interface.js.map +1 -0
- package/dist/interface/metrics.interface.d.ts +12 -0
- package/dist/interface/metrics.interface.js +3 -0
- package/dist/interface/metrics.interface.js.map +1 -0
- package/dist/interface/queue-options.interface.d.ts +84 -0
- package/dist/interface/queue-options.interface.js +3 -0
- package/dist/interface/queue-options.interface.js.map +1 -0
- package/dist/interface/queue-provider.interface.d.ts +55 -0
- package/dist/interface/queue-provider.interface.js +7 -0
- package/dist/interface/queue-provider.interface.js.map +1 -0
- package/dist/module/index.d.ts +3 -0
- package/dist/module/index.js +20 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/queue.module-definition.d.ts +2 -0
- package/dist/module/queue.module-definition.js +11 -0
- package/dist/module/queue.module-definition.js.map +1 -0
- package/dist/module/queue.module.d.ts +3 -0
- package/dist/module/queue.module.js +26 -0
- package/dist/module/queue.module.js.map +1 -0
- package/dist/module/queue.provider.d.ts +2 -0
- package/dist/module/queue.provider.js +57 -0
- package/dist/module/queue.provider.js.map +1 -0
- package/dist/provider/bullmq/bullmq.options.d.ts +12 -0
- package/dist/provider/bullmq/bullmq.options.js +3 -0
- package/dist/provider/bullmq/bullmq.options.js.map +1 -0
- package/dist/provider/bullmq/bullmq.provider.d.ts +52 -0
- package/dist/provider/bullmq/bullmq.provider.js +476 -0
- package/dist/provider/bullmq/bullmq.provider.js.map +1 -0
- package/dist/provider/bullmq/index.d.ts +1 -0
- package/dist/provider/bullmq/index.js +18 -0
- package/dist/provider/bullmq/index.js.map +1 -0
- package/dist/provider/index.d.ts +4 -0
- package/dist/provider/index.js +21 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/provider/kafka/index.d.ts +1 -0
- package/dist/provider/kafka/index.js +18 -0
- package/dist/provider/kafka/index.js.map +1 -0
- package/dist/provider/kafka/kafka.provider.d.ts +59 -0
- package/dist/provider/kafka/kafka.provider.js +598 -0
- package/dist/provider/kafka/kafka.provider.js.map +1 -0
- package/dist/provider/rabbitmq/index.d.ts +1 -0
- package/dist/provider/rabbitmq/index.js +18 -0
- package/dist/provider/rabbitmq/index.js.map +1 -0
- package/dist/provider/rabbitmq/rabbitmq.provider.d.ts +48 -0
- package/dist/provider/rabbitmq/rabbitmq.provider.js +498 -0
- package/dist/provider/rabbitmq/rabbitmq.provider.js.map +1 -0
- package/dist/provider/redis-pubsub/index.d.ts +1 -0
- package/dist/provider/redis-pubsub/index.js +18 -0
- package/dist/provider/redis-pubsub/index.js.map +1 -0
- package/dist/provider/redis-pubsub/redis-pubsub.provider.d.ts +40 -0
- package/dist/provider/redis-pubsub/redis-pubsub.provider.js +226 -0
- package/dist/provider/redis-pubsub/redis-pubsub.provider.js.map +1 -0
- package/dist/service/index.d.ts +1 -0
- package/dist/service/index.js +18 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/queue.service.d.ts +36 -0
- package/dist/service/queue.service.js +89 -0
- package/dist/service/queue.service.js.map +1 -0
- package/dist/store/in-memory-idempotency.store.d.ts +15 -0
- package/dist/store/in-memory-idempotency.store.js +84 -0
- package/dist/store/in-memory-idempotency.store.js.map +1 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +6 -0
- package/dist/store/index.js.map +1 -0
- package/dist/utils/circuit-breaker.d.ts +30 -0
- package/dist/utils/circuit-breaker.js +133 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/dist/utils/delayed-scheduler.d.ts +16 -0
- package/dist/utils/delayed-scheduler.js +100 -0
- package/dist/utils/delayed-scheduler.js.map +1 -0
- package/dist/utils/errors.d.ts +23 -0
- package/dist/utils/errors.js +85 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lock-renewal.d.ts +14 -0
- package/dist/utils/lock-renewal.js +61 -0
- package/dist/utils/lock-renewal.js.map +1 -0
- package/dist/utils/redis-idempotency-store.d.ts +21 -0
- package/dist/utils/redis-idempotency-store.js +88 -0
- package/dist/utils/redis-idempotency-store.js.map +1 -0
- package/dist/utils/sanitize.d.ts +3 -0
- package/dist/utils/sanitize.js +55 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/validation.d.ts +8 -0
- package/dist/utils/validation.js +60 -0
- package/dist/utils/validation.js.map +1 -0
- package/docker-compose.e2e.yml +69 -0
- package/docs/FINAL_CODE_REVIEW.md +328 -0
- package/docs/IMPLEMENTATION_PLAN.md +748 -0
- package/docs/archive/CIRCUIT_BREAKER_PLAN.md +35 -0
- package/docs/archive/CODE_REVIEW.md +596 -0
- package/docs/archive/CODE_REVIEW_V2.md +1081 -0
- package/docs/archive/CODE_REVIEW_V3.md +402 -0
- package/docs/archive/IMPLEMENTATION_PLAN.md +505 -0
- package/docs/archive/IMPLEMENTATION_PLAN_BUGFIX.md +428 -0
- package/package.json +70 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @nathapp/nestjs-queue
|
|
2
|
+
|
|
3
|
+
Multi-provider queue abstraction for NestJS (BullMQ, Kafka, RabbitMQ, Redis Pub/Sub).
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
- Build: `bun run build` (from monorepo root)
|
|
7
|
+
- Test: `bun run --filter @nathapp/nestjs-queue test`
|
|
8
|
+
- E2E: `bun run --filter @nathapp/nestjs-queue test:e2e`
|
|
9
|
+
- Lint: `bun run lint`
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
- `lib/provider/` - Provider implementations (BullMQ, Kafka, RabbitMQ, Redis)
|
|
13
|
+
- `lib/interface/` - Core interfaces (IQueueProvider, IJob, etc.)
|
|
14
|
+
- `lib/explorer/` - ProcessorExplorer for decorator scanning
|
|
15
|
+
- `lib/utils/` - Shared utilities (errors, validation, idempotency)
|
|
16
|
+
|
|
17
|
+
## Style
|
|
18
|
+
- All providers must implement `IQueueProvider` interface
|
|
19
|
+
- Use `QueueError` for domain errors with error codes
|
|
20
|
+
- Propagate `correlationId` through all job flows
|
|
21
|
+
- Clean up resources in `close()` with `ShutdownOptions`
|
|
22
|
+
|
|
23
|
+
## IMPORTANT
|
|
24
|
+
- Never break the `IQueueProvider` interface contract
|
|
25
|
+
- All new features must have unit tests
|
|
26
|
+
- E2E tests require Docker (docker-compose.e2e.yml)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🔴 Queue Module Safety Checklist
|
|
31
|
+
|
|
32
|
+
**Always verify these when modifying queue code:**
|
|
33
|
+
|
|
34
|
+
### Memory Leaks
|
|
35
|
+
- [ ] All Maps/Sets cleared in `close()` method
|
|
36
|
+
- [ ] All event listeners removed on destroy (`removeAllListeners`)
|
|
37
|
+
- [ ] Timer/interval cleanup (`clearInterval`, `clearTimeout`)
|
|
38
|
+
- [ ] No unbounded caches (add TTL or max size)
|
|
39
|
+
- [ ] Health check doesn't create persistent resources
|
|
40
|
+
|
|
41
|
+
### Race Conditions
|
|
42
|
+
- [ ] Single worker per queue (ProcessorExplorer routing pattern)
|
|
43
|
+
- [ ] No duplicate worker registration (throw WORKER_EXISTS)
|
|
44
|
+
- [ ] Idempotency store lock before processing
|
|
45
|
+
- [ ] Lock renewal for long-running jobs (> lockTtl)
|
|
46
|
+
|
|
47
|
+
### Duplicate Job Prevention
|
|
48
|
+
- [ ] Idempotency store configured for production
|
|
49
|
+
- [ ] Original job ID preserved across retries (x-original-job-id)
|
|
50
|
+
- [ ] Consumer group / prefetch configured correctly
|
|
51
|
+
- [ ] Deduplication key includes partition+offset (Kafka)
|
|
52
|
+
|
|
53
|
+
### Job Loss on Restart
|
|
54
|
+
- [ ] Avoid in-memory delayed jobs (use broker-native delays)
|
|
55
|
+
- [ ] DelayedJobScheduler.shutdown({ executeImmediately: true })
|
|
56
|
+
- [ ] Kubernetes terminationGracePeriodSeconds >= shutdown timeout
|
|
57
|
+
- [ ] Ack AFTER successful retry add (RabbitMQ)
|
|
58
|
+
- [ ] Graceful shutdown: close workers → events → queues
|
|
59
|
+
|
|
60
|
+
### Security
|
|
61
|
+
- [ ] Sanitize correlationId (alphanumeric, hyphen, underscore only)
|
|
62
|
+
- [ ] Validate job structure before processing
|
|
63
|
+
- [ ] No credentials in URLs/logs
|
|
64
|
+
- [ ] Sanitize error messages before DLQ/logs
|
|
65
|
+
|
|
66
|
+
### Testing
|
|
67
|
+
- [ ] Reset circuit breaker in `beforeEach` for isolation
|
|
68
|
+
- [ ] Unique queue names per test to avoid WORKER_EXISTS
|
|
69
|
+
- [ ] Wait for worker ready before adding jobs
|
|
70
|
+
- [ ] Account for async processing in assertions
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Circuit Breaker Notes
|
|
75
|
+
- State persists across tests (call `processorExplorer.resetCircuitBreaker()`)
|
|
76
|
+
- Reset timeout affects test timing (use 10s+ for reliable tests)
|
|
77
|
+
- OPEN state re-throws error to trigger provider retry
|
|
78
|
+
- Non-failure errors (per `isFailure`) count as successes for recovery
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Quick Reference
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Idempotency pattern (all providers)
|
|
86
|
+
const canProcess = await store.markProcessing(job.id, lockTtl);
|
|
87
|
+
if (!canProcess) return; // Skip duplicate
|
|
88
|
+
try {
|
|
89
|
+
await process(job);
|
|
90
|
+
await store.markComplete(job.id, completedTtl);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
await store.releaseLock(job.id); // Allow retry
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Safe retry pattern (RabbitMQ)
|
|
97
|
+
await this.add(queueName, job.name, data, retryOpts); // Add FIRST
|
|
98
|
+
channel.ack(msg); // Ack AFTER successful add
|
|
99
|
+
|
|
100
|
+
// Cleanup pattern (close method)
|
|
101
|
+
await Promise.all(workers.map(w => w.close()));
|
|
102
|
+
workers.clear();
|
|
103
|
+
events.clear();
|
|
104
|
+
queues.clear();
|
|
105
|
+
listeners.clear();
|
|
106
|
+
```
|
package/TODO.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# TODO: @nathapp/nestjs-queue
|
|
2
|
+
|
|
3
|
+
## ✅ Done
|
|
4
|
+
- [x] Phase 0: Reach 80% Branch Coverage (Final: 81.08%)
|
|
5
|
+
- [x] test/provider/rabbitmq.provider.spec.ts (80.3% coverage)
|
|
6
|
+
- [x] test/provider/kafka.provider.spec.ts (82.1% coverage)
|
|
7
|
+
- [x] Phase 1: `InMemoryIdempotencyStore` Implementation (25 tests)
|
|
8
|
+
- [x] Final Code Review: Memory Leak & Security Fixes (148/148 tests)
|
|
9
|
+
- [x] E2E Validation (Confirmed by William)
|
|
10
|
+
- Fixed BullMQ listenerRegistry memory leak
|
|
11
|
+
- Fixed BullMQ isHealthy() queue persistence leak
|
|
12
|
+
- Fixed Kafka verifiedTopics memory leak
|
|
13
|
+
- Fixed ProcessorExplorer event listener leak
|
|
14
|
+
- Added JSON structure validation
|
|
15
|
+
- Added correlationId sanitization
|
|
16
|
+
- [x] E2E Test Fixes
|
|
17
|
+
- Fixed RabbitMQ addBulk() to await publish confirmation
|
|
18
|
+
- Fixed event listener removal with removeListener()
|
|
19
|
+
- Fixed event listener test isolation
|
|
20
|
+
- Fixed circuit breaker timing and rejection handling
|
|
21
|
+
- All E2E tests passing
|
|
22
|
+
- [x] Push changes to `queue-module` branch (Complete ad92943)
|
|
23
|
+
- [x] Implement Circuit Breaker Pattern (P3.14) - 123/123 tests passing
|
|
24
|
+
- [x] Refactor `ProcessorExplorer` for single-worker routing
|
|
25
|
+
- [x] Fix `ProcessorExplorer` test regressions (18/18 passing)
|
|
26
|
+
- [x] Implement P1: `off()` Method
|
|
27
|
+
- [x] Implement P1: Health Checks
|
|
28
|
+
- [x] Implement P1: Kafka Idempotency Store
|
|
29
|
+
- [x] Implement P1: Metrics Hooks
|
|
30
|
+
- [x] Implement P1: Duplicate Worker Handling
|
|
31
|
+
- [x] Implement P2: RabbitMQ Atomic `addBulk()`
|
|
32
|
+
- [x] Implement P2: Kafka CorrelationId Propagation
|
|
33
|
+
- [x] Implement P2: ProcessorExplorer Error Boundary
|
|
34
|
+
- [x] Implement P2: Job Progress API
|
|
35
|
+
- [x] Implement P2: ShutdownOptions in QueueService
|
|
36
|
+
- [x] Verify full test suite (103/103 passing)
|
|
37
|
+
- [x] Build package successfully
|
|
38
|
+
- [x] Workspace Cleanup & Document Archiving
|
|
39
|
+
|
|
40
|
+
## 🔵 Backlog / Nice to Have
|
|
41
|
+
- [ ] `getQueueStats()` Method
|
|
42
|
+
- [ ] Support for Job Scheduling (Cron-like)
|
|
43
|
+
- [ ] Job TTL Enforcement
|
|
44
|
+
- [ ] Batch Processing Mode (High Throughput)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './queue.constant';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./queue.constant"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/constant/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const QUEUE_MODULE_OPTIONS = "QUEUE_MODULE_OPTIONS";
|
|
2
|
+
export declare const QUEUE_PROVIDER = "QUEUE_PROVIDER";
|
|
3
|
+
export declare const QUEUE_SERVICE = "QUEUE_SERVICE";
|
|
4
|
+
export declare const PROCESSOR_METADATA = "PROCESSOR_METADATA";
|
|
5
|
+
export declare const PROCESS_METADATA = "PROCESS_METADATA";
|
|
6
|
+
export declare const ON_QUEUE_EVENT_METADATA = "ON_QUEUE_EVENT_METADATA";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ON_QUEUE_EVENT_METADATA = exports.PROCESS_METADATA = exports.PROCESSOR_METADATA = exports.QUEUE_SERVICE = exports.QUEUE_PROVIDER = exports.QUEUE_MODULE_OPTIONS = void 0;
|
|
4
|
+
exports.QUEUE_MODULE_OPTIONS = 'QUEUE_MODULE_OPTIONS';
|
|
5
|
+
exports.QUEUE_PROVIDER = 'QUEUE_PROVIDER';
|
|
6
|
+
exports.QUEUE_SERVICE = 'QUEUE_SERVICE';
|
|
7
|
+
exports.PROCESSOR_METADATA = 'PROCESSOR_METADATA';
|
|
8
|
+
exports.PROCESS_METADATA = 'PROCESS_METADATA';
|
|
9
|
+
exports.ON_QUEUE_EVENT_METADATA = 'ON_QUEUE_EVENT_METADATA';
|
|
10
|
+
//# sourceMappingURL=queue.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.constant.js","sourceRoot":"","sources":["../../lib/constant/queue.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,aAAa,GAAG,eAAe,CAAC;AAChC,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,uBAAuB,GAAG,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./processor.decorator"), exports);
|
|
18
|
+
__exportStar(require("./process.decorator"), exports);
|
|
19
|
+
__exportStar(require("./on-queue-event.decorator"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/decorator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,sDAAoC;AACpC,6DAA2C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnQueueEvent = OnQueueEvent;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const queue_constant_1 = require("../constant/queue.constant");
|
|
6
|
+
function OnQueueEvent(eventOrOptions) {
|
|
7
|
+
const opts = typeof eventOrOptions === 'string'
|
|
8
|
+
? { event: eventOrOptions }
|
|
9
|
+
: eventOrOptions;
|
|
10
|
+
return (target, propertyKey, descriptor) => {
|
|
11
|
+
(0, common_1.SetMetadata)(queue_constant_1.ON_QUEUE_EVENT_METADATA, {
|
|
12
|
+
...opts,
|
|
13
|
+
methodName: propertyKey,
|
|
14
|
+
})(target, propertyKey, descriptor);
|
|
15
|
+
return descriptor;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=on-queue-event.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-queue-event.decorator.js","sourceRoot":"","sources":["../../lib/decorator/on-queue-event.decorator.ts"],"names":[],"mappings":";;AAwCA,oCAmBC;AA3DD,2CAA6C;AAC7C,+DAAqE;AAuCrE,SAAgB,YAAY,CAC1B,cAAyD;IAEzD,MAAM,IAAI,GACR,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,EAAE,KAAK,EAAE,cAA4B,EAAE;QACzC,CAAC,CAAC,cAAc,CAAC;IAErB,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;QACF,IAAA,oBAAW,EAAC,wCAAuB,EAAE;YACnC,GAAG,IAAI;YACP,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QACpC,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Process = Process;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const queue_constant_1 = require("../constant/queue.constant");
|
|
6
|
+
function Process(nameOrOptions) {
|
|
7
|
+
const opts = typeof nameOrOptions === 'string'
|
|
8
|
+
? { name: nameOrOptions }
|
|
9
|
+
: nameOrOptions || {};
|
|
10
|
+
return (target, propertyKey, descriptor) => {
|
|
11
|
+
(0, common_1.SetMetadata)(queue_constant_1.PROCESS_METADATA, {
|
|
12
|
+
...opts,
|
|
13
|
+
methodName: propertyKey,
|
|
14
|
+
})(target, propertyKey, descriptor);
|
|
15
|
+
return descriptor;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=process.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.decorator.js","sourceRoot":"","sources":["../../lib/decorator/process.decorator.ts"],"names":[],"mappings":";;AAuCA,0BAiBC;AAxDD,2CAA6C;AAC7C,+DAA8D;AAsC9D,SAAgB,OAAO,CAAC,aAAgD;IACtE,MAAM,IAAI,GACR,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE;QACzB,CAAC,CAAC,aAAa,IAAI,EAAE,CAAC;IAE1B,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EAC9B,EAAE;QACF,IAAA,oBAAW,EAAC,iCAAgB,EAAE;YAC5B,GAAG,IAAI;YACP,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QACpC,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Processor = Processor;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const queue_constant_1 = require("../constant/queue.constant");
|
|
6
|
+
function Processor(options) {
|
|
7
|
+
const opts = typeof options === 'string' ? { queueName: options } : options;
|
|
8
|
+
return (target) => {
|
|
9
|
+
(0, common_1.SetMetadata)(queue_constant_1.PROCESSOR_METADATA, opts)(target);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=processor.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processor.decorator.js","sourceRoot":"","sources":["../../lib/decorator/processor.decorator.ts"],"names":[],"mappings":";;AA8BA,8BAOC;AArCD,2CAA6C;AAC7C,+DAAgE;AA6BhE,SAAgB,SAAS,CAAC,OAA2C;IACnE,MAAM,IAAI,GACR,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAEjE,OAAO,CAAC,MAAgB,EAAE,EAAE;QAC1B,IAAA,oBAAW,EAAC,mCAAkB,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./provider.enum"), exports);
|
|
18
|
+
__exportStar(require("./job-status.enum"), exports);
|
|
19
|
+
__exportStar(require("./queue-event.enum"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/enum/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,oDAAkC;AAClC,qDAAmC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JobStatus = void 0;
|
|
4
|
+
var JobStatus;
|
|
5
|
+
(function (JobStatus) {
|
|
6
|
+
JobStatus["WAITING"] = "waiting";
|
|
7
|
+
JobStatus["ACTIVE"] = "active";
|
|
8
|
+
JobStatus["COMPLETED"] = "completed";
|
|
9
|
+
JobStatus["FAILED"] = "failed";
|
|
10
|
+
JobStatus["DELAYED"] = "delayed";
|
|
11
|
+
JobStatus["PAUSED"] = "paused";
|
|
12
|
+
})(JobStatus || (exports.JobStatus = JobStatus = {}));
|
|
13
|
+
//# sourceMappingURL=job-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-status.enum.js","sourceRoot":"","sources":["../../lib/enum/job-status.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;IACjB,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;AACnB,CAAC,EAPW,SAAS,yBAAT,SAAS,QAOpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueProviderType = void 0;
|
|
4
|
+
var QueueProviderType;
|
|
5
|
+
(function (QueueProviderType) {
|
|
6
|
+
QueueProviderType["BULLMQ"] = "bullmq";
|
|
7
|
+
QueueProviderType["KAFKA"] = "kafka";
|
|
8
|
+
QueueProviderType["RABBITMQ"] = "rabbitmq";
|
|
9
|
+
QueueProviderType["REDIS_PUBSUB"] = "redis-pubsub";
|
|
10
|
+
QueueProviderType["CUSTOM"] = "custom";
|
|
11
|
+
})(QueueProviderType || (exports.QueueProviderType = QueueProviderType = {}));
|
|
12
|
+
//# sourceMappingURL=provider.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.enum.js","sourceRoot":"","sources":["../../lib/enum/provider.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,oCAAe,CAAA;IACf,0CAAqB,CAAA;IACrB,kDAA6B,CAAA;IAC7B,sCAAiB,CAAA;AACnB,CAAC,EANW,iBAAiB,iCAAjB,iBAAiB,QAM5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueEvent = void 0;
|
|
4
|
+
var QueueEvent;
|
|
5
|
+
(function (QueueEvent) {
|
|
6
|
+
QueueEvent["COMPLETED"] = "completed";
|
|
7
|
+
QueueEvent["FAILED"] = "failed";
|
|
8
|
+
QueueEvent["PROGRESS"] = "progress";
|
|
9
|
+
QueueEvent["ACTIVE"] = "active";
|
|
10
|
+
QueueEvent["WAITING"] = "waiting";
|
|
11
|
+
QueueEvent["STALLED"] = "stalled";
|
|
12
|
+
QueueEvent["REMOVED"] = "removed";
|
|
13
|
+
QueueEvent["DRAINED"] = "drained";
|
|
14
|
+
QueueEvent["ERROR"] = "error";
|
|
15
|
+
})(QueueEvent || (exports.QueueEvent = QueueEvent = {}));
|
|
16
|
+
//# sourceMappingURL=queue-event.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-event.enum.js","sourceRoot":"","sources":["../../lib/enum/queue-event.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAUX;AAVD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;AACjB,CAAC,EAVW,UAAU,0BAAV,UAAU,QAUrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './processor.explorer';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./processor.explorer"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/explorer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
|
|
3
|
+
import { IQueueProvider } from '../interface/queue-provider.interface';
|
|
4
|
+
import { QueueModuleOptions } from '../interface/queue-options.interface';
|
|
5
|
+
export declare class ProcessorExplorer implements OnModuleInit, OnModuleDestroy {
|
|
6
|
+
private readonly discoveryService;
|
|
7
|
+
private readonly metadataScanner;
|
|
8
|
+
private readonly reflector;
|
|
9
|
+
private readonly queueProvider;
|
|
10
|
+
private readonly moduleOptions?;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private readonly queueHandlers;
|
|
13
|
+
private readonly circuitBreakers;
|
|
14
|
+
constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, reflector: Reflector, queueProvider: IQueueProvider, moduleOptions?: QueueModuleOptions);
|
|
15
|
+
onModuleInit(): Promise<void>;
|
|
16
|
+
onModuleDestroy(): void;
|
|
17
|
+
private explore;
|
|
18
|
+
private collectProcessHandler;
|
|
19
|
+
private mergeCircuitBreakerOptions;
|
|
20
|
+
private registerQueueWorkers;
|
|
21
|
+
private getMetricsHook;
|
|
22
|
+
private registerEventHandler;
|
|
23
|
+
resetCircuitBreaker(queueName: string): void;
|
|
24
|
+
resetAllCircuitBreakers(): void;
|
|
25
|
+
}
|