atomic-queues 1.0.15 → 1.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-queues.module.js","sourceRoot":"","sources":["../../src/module/atomic-queues.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAMwB;AACxB,sDAA4B;AAE5B,0CAcqB;AA6BrB;;GAEG;AACH,MAAM,aAAa,GAAe;IAChC,8BAAmB;IACnB,+BAAoB;IACpB,8BAAmB;IACnB,8BAAmB;IACnB,+BAAoB;IACpB,iCAAsB;IACtB,6BAAkB;IAClB,6BAAkB;IAClB,8BAAmB;IACnB,+BAAoB;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGI,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAC7B;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,MAAiC;QAC9C,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAEvD,OAAO;YACL,MAAM,EAAE,oBAAkB;YAC1B,qEAAqE;YACrE,mDAAmD;YACnD,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,+BAAoB;oBAC7B,QAAQ,EAAE,MAAM;iBACjB;gBACD,aAAa;gBACb,GAAG,aAAa;aACjB;YACD,OAAO,EAAE;gBACP,+BAAoB;gBACpB,8BAAmB;gBACnB,GAAG,aAAa;aACjB;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAuC;QACzD,MAAM,cAAc,GAAG,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEtD,OAAO;YACL,MAAM,EAAE,oBAAkB;YAC1B,qEAAqE;YACrE,mDAAmD;YACnD,OAAO,EAAE,CAAC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E,+BAAoB;YAC7B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAU;SACxC,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,wBAAwB;QACrC,OAAO;YACL,OAAO,EAAE,8BAAmB;YAC5B,UAAU,EAAE,CAAC,MAAiC,EAAE,EAAE;gBAChD,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;oBACrB,OAAO,IAAI,iBAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;wBACjC,oBAAoB,EAAE,MAAM,CAAC,KAAK,CAAC,oBAAoB,IAAI,IAAI;qBAChE,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,IAAI,iBAAK,CAAC;oBACf,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,WAAW;oBACtC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI;oBAC/B,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;oBAC/B,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;oBACnB,oBAAoB,EAAE,MAAM,CAAC,KAAK,CAAC,oBAAoB,IAAI,IAAI;iBAChE,CAAC,CAAC;YACL,CAAC;YACD,MAAM,EAAE,CAAC,+BAAoB,CAAC;SAC/B,CAAC;IACJ,CAAC;CACF,CAAA;AAlJY,gDAAkB;6BAAlB,kBAAkB;IAF9B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,kBAAkB,CAkJ9B"}
@@ -7,4 +7,5 @@ export * from './cron-manager';
7
7
  export * from './index-manager';
8
8
  export * from './service-queue';
9
9
  export * from './shutdown-state';
10
+ export * from './processor-discovery';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
@@ -23,4 +23,5 @@ __exportStar(require("./cron-manager"), exports);
23
23
  __exportStar(require("./index-manager"), exports);
24
24
  __exportStar(require("./service-queue"), exports);
25
25
  __exportStar(require("./shutdown-state"), exports);
26
+ __exportStar(require("./processor-discovery"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,kDAAgC;AAChC,mDAAiC;AACjC,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B;AAC/B,kDAAgC;AAChC,kDAAgC;AAChC,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,kDAAgC;AAChC,mDAAiC;AACjC,kDAAgC;AAChC,kDAAgC;AAChC,iDAA+B;AAC/B,kDAAgC;AAChC,kDAAgC;AAChC,mDAAiC;AACjC,wDAAsC"}
@@ -0,0 +1,2 @@
1
+ export * from './processor-discovery.service';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/processor-discovery/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
@@ -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-discovery.service"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/processor-discovery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C"}
@@ -0,0 +1,141 @@
1
+ import { OnModuleInit, Type } from '@nestjs/common';
2
+ import { ModuleRef, DiscoveryService, MetadataScanner } from '@nestjs/core';
3
+ import { WorkerProcessorOptions, EntityScalerOptions } from '../../decorators';
4
+ import { WorkerManagerService } from '../worker-manager';
5
+ import { QueueManagerService } from '../queue-manager';
6
+ import { CronManagerService } from '../cron-manager';
7
+ import { IAtomicQueuesModuleConfig } from '../../domain';
8
+ /**
9
+ * Registered processor info
10
+ */
11
+ export interface RegisteredProcessor {
12
+ entityType: string;
13
+ processorInstance: any;
14
+ options: WorkerProcessorOptions;
15
+ jobHandlers: Map<string, {
16
+ method: string;
17
+ isWildcard: boolean;
18
+ }>;
19
+ wildcardHandler?: {
20
+ method: string;
21
+ };
22
+ queueNameFn: (entityId: string) => string;
23
+ workerNameFn: (entityId: string) => string;
24
+ }
25
+ /**
26
+ * Registered scaler info
27
+ */
28
+ export interface RegisteredScaler {
29
+ entityType: string;
30
+ scalerInstance: any;
31
+ options: EntityScalerOptions;
32
+ methods: {
33
+ getActiveEntities?: string;
34
+ getDesiredWorkerCount?: string;
35
+ onSpawnWorker?: string;
36
+ onTerminateWorker?: string;
37
+ };
38
+ }
39
+ /**
40
+ * ProcessorDiscoveryService
41
+ *
42
+ * Automatically discovers and registers classes decorated with:
43
+ * - @WorkerProcessor - For job processing
44
+ * - @EntityScaler - For entity scaling logic
45
+ *
46
+ * This service bridges the decorator-based API with the core services:
47
+ * - WorkerManagerService - For worker lifecycle
48
+ * - QueueManagerService - For queue management
49
+ * - CronManagerService - For automatic scaling
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Classes are auto-discovered from module providers
54
+ * @WorkerProcessor({ entityType: 'table' })
55
+ * @Injectable()
56
+ * export class TableProcessor {
57
+ * @JobHandler('make-bet')
58
+ * async handleMakeBet(job: Job, entityId: string) { ... }
59
+ * }
60
+ *
61
+ * @EntityScaler({ entityType: 'table' })
62
+ * @Injectable()
63
+ * export class TableScaler {
64
+ * @GetActiveEntities()
65
+ * async getAllTables() { ... }
66
+ * }
67
+ * ```
68
+ */
69
+ export declare class ProcessorDiscoveryService implements OnModuleInit {
70
+ private readonly discoveryService;
71
+ private readonly metadataScanner;
72
+ private readonly moduleRef;
73
+ private readonly workerManager;
74
+ private readonly queueManager;
75
+ private readonly cronManager;
76
+ private readonly config;
77
+ private readonly logger;
78
+ private readonly processors;
79
+ private readonly scalers;
80
+ private readonly activeWorkers;
81
+ constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, moduleRef: ModuleRef, workerManager: WorkerManagerService, queueManager: QueueManagerService, cronManager: CronManagerService, config: IAtomicQueuesModuleConfig);
82
+ onModuleInit(): Promise<void>;
83
+ /**
84
+ * Discover all @WorkerProcessor decorated classes
85
+ */
86
+ private discoverProcessors;
87
+ /**
88
+ * Discover all @EntityScaler decorated classes
89
+ */
90
+ private discoverScalers;
91
+ /**
92
+ * Register a processor from discovered metadata
93
+ */
94
+ private registerProcessor;
95
+ /**
96
+ * Register a scaler from discovered metadata
97
+ */
98
+ private registerScaler;
99
+ /**
100
+ * Register scalers with CronManager for automatic scaling
101
+ */
102
+ private registerScalersWithCronManager;
103
+ /**
104
+ * Create a worker for an entity using the registered processor
105
+ */
106
+ createWorkerForEntity(entityType: string, entityId: string): Promise<void>;
107
+ /**
108
+ * Process a job using the registered handlers
109
+ */
110
+ private processJob;
111
+ /**
112
+ * Manually register a processor class
113
+ * Use this when auto-discovery is not available or for dynamic registration
114
+ */
115
+ registerProcessorClass<T>(processorClass: Type<T>, instance?: T): Promise<void>;
116
+ /**
117
+ * Manually register a scaler class
118
+ */
119
+ registerScalerClass<T>(scalerClass: Type<T>, instance?: T): Promise<void>;
120
+ /**
121
+ * Get registered processor for an entity type
122
+ */
123
+ getProcessor(entityType: string): RegisteredProcessor | undefined;
124
+ /**
125
+ * Get registered scaler for an entity type
126
+ */
127
+ getScaler(entityType: string): RegisteredScaler | undefined;
128
+ /**
129
+ * Get all registered entity types
130
+ */
131
+ getRegisteredEntityTypes(): string[];
132
+ /**
133
+ * Check if a worker exists for an entity
134
+ */
135
+ hasActiveWorker(entityType: string, entityId: string): boolean;
136
+ /**
137
+ * Get all active workers for an entity type
138
+ */
139
+ getActiveWorkers(entityType: string): string[];
140
+ }
141
+ //# sourceMappingURL=processor-discovery.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processor-discovery.service.d.ts","sourceRoot":"","sources":["../../../src/services/processor-discovery/processor-discovery.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACZ,IAAI,EAGL,MAA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O,CAAC,IAAI,CAAC;IAYhB;;OAEG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAIjE;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI3D;;OAEG;IACH,wBAAwB,IAAI,MAAM,EAAE;IAMpC;;OAEG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9D;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;CAG/C"}
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var ProcessorDiscoveryService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ProcessorDiscoveryService = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const core_1 = require("@nestjs/core");
19
+ const decorators_1 = require("../../decorators");
20
+ const worker_manager_1 = require("../worker-manager");
21
+ const queue_manager_1 = require("../queue-manager");
22
+ const cron_manager_1 = require("../cron-manager");
23
+ const constants_1 = require("../constants");
24
+ /**
25
+ * ProcessorDiscoveryService
26
+ *
27
+ * Automatically discovers and registers classes decorated with:
28
+ * - @WorkerProcessor - For job processing
29
+ * - @EntityScaler - For entity scaling logic
30
+ *
31
+ * This service bridges the decorator-based API with the core services:
32
+ * - WorkerManagerService - For worker lifecycle
33
+ * - QueueManagerService - For queue management
34
+ * - CronManagerService - For automatic scaling
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Classes are auto-discovered from module providers
39
+ * @WorkerProcessor({ entityType: 'table' })
40
+ * @Injectable()
41
+ * export class TableProcessor {
42
+ * @JobHandler('make-bet')
43
+ * async handleMakeBet(job: Job, entityId: string) { ... }
44
+ * }
45
+ *
46
+ * @EntityScaler({ entityType: 'table' })
47
+ * @Injectable()
48
+ * export class TableScaler {
49
+ * @GetActiveEntities()
50
+ * async getAllTables() { ... }
51
+ * }
52
+ * ```
53
+ */
54
+ let ProcessorDiscoveryService = ProcessorDiscoveryService_1 = class ProcessorDiscoveryService {
55
+ constructor(discoveryService, metadataScanner, moduleRef, workerManager, queueManager, cronManager, config) {
56
+ this.discoveryService = discoveryService;
57
+ this.metadataScanner = metadataScanner;
58
+ this.moduleRef = moduleRef;
59
+ this.workerManager = workerManager;
60
+ this.queueManager = queueManager;
61
+ this.cronManager = cronManager;
62
+ this.config = config;
63
+ this.logger = new common_1.Logger(ProcessorDiscoveryService_1.name);
64
+ this.processors = new Map();
65
+ this.scalers = new Map();
66
+ this.activeWorkers = new Map(); // entityType -> Set of entityIds with workers
67
+ }
68
+ async onModuleInit() {
69
+ if (!this.discoveryService) {
70
+ this.logger.warn('DiscoveryService not available. Manual registration required.');
71
+ return;
72
+ }
73
+ await this.discoverProcessors();
74
+ await this.discoverScalers();
75
+ await this.registerScalersWithCronManager();
76
+ }
77
+ /**
78
+ * Discover all @WorkerProcessor decorated classes
79
+ */
80
+ async discoverProcessors() {
81
+ const providers = this.discoveryService.getProviders();
82
+ for (const wrapper of providers) {
83
+ const { instance, metatype } = wrapper;
84
+ if (!instance || !metatype)
85
+ continue;
86
+ // Cast to Type<any> for metadata functions
87
+ const targetClass = metatype;
88
+ const options = (0, decorators_1.getWorkerProcessorMetadata)(targetClass);
89
+ if (!options)
90
+ continue;
91
+ this.registerProcessor(targetClass, instance, options);
92
+ }
93
+ this.logger.log(`Discovered ${this.processors.size} worker processor(s): ${Array.from(this.processors.keys()).join(', ')}`);
94
+ }
95
+ /**
96
+ * Discover all @EntityScaler decorated classes
97
+ */
98
+ async discoverScalers() {
99
+ const providers = this.discoveryService.getProviders();
100
+ for (const wrapper of providers) {
101
+ const { instance, metatype } = wrapper;
102
+ if (!instance || !metatype)
103
+ continue;
104
+ // Cast to Type<any> for metadata functions
105
+ const targetClass = metatype;
106
+ const options = (0, decorators_1.getEntityScalerMetadata)(targetClass);
107
+ if (!options)
108
+ continue;
109
+ this.registerScaler(targetClass, instance, options);
110
+ }
111
+ this.logger.log(`Discovered ${this.scalers.size} entity scaler(s): ${Array.from(this.scalers.keys()).join(', ')}`);
112
+ }
113
+ /**
114
+ * Register a processor from discovered metadata
115
+ */
116
+ registerProcessor(metatype, instance, options) {
117
+ const { entityType } = options;
118
+ // Build job handlers map
119
+ const handlers = (0, decorators_1.getJobHandlerMetadata)(metatype);
120
+ const jobHandlers = new Map();
121
+ let wildcardHandler;
122
+ for (const handler of handlers) {
123
+ if (handler.isWildcard) {
124
+ wildcardHandler = { method: handler.methodName };
125
+ }
126
+ else {
127
+ jobHandlers.set(handler.jobName, {
128
+ method: handler.methodName,
129
+ isWildcard: false,
130
+ });
131
+ }
132
+ }
133
+ // Build queue and worker name functions
134
+ const keyPrefix = this.config.keyPrefix || 'aq';
135
+ const queueNameFn = typeof options.queueName === 'function'
136
+ ? options.queueName
137
+ : options.queueName
138
+ ? () => options.queueName
139
+ : (entityId) => `${keyPrefix}:${entityType}:${entityId}:queue`;
140
+ const workerNameFn = typeof options.workerName === 'function'
141
+ ? options.workerName
142
+ : options.workerName
143
+ ? () => options.workerName
144
+ : (entityId) => `${keyPrefix}:${entityType}:${entityId}:worker`;
145
+ const processor = {
146
+ entityType,
147
+ processorInstance: instance,
148
+ options,
149
+ jobHandlers,
150
+ wildcardHandler,
151
+ queueNameFn,
152
+ workerNameFn,
153
+ };
154
+ this.processors.set(entityType, processor);
155
+ this.activeWorkers.set(entityType, new Set());
156
+ this.logger.debug(`Registered processor for entity type '${entityType}' with ${jobHandlers.size} job handlers` +
157
+ (wildcardHandler ? ' and wildcard handler' : ''));
158
+ }
159
+ /**
160
+ * Register a scaler from discovered metadata
161
+ */
162
+ registerScaler(metatype, instance, options) {
163
+ const { entityType } = options;
164
+ // Find decorated methods
165
+ const methods = {
166
+ getActiveEntities: Reflect.getMetadata(decorators_1.GET_ACTIVE_ENTITIES_METADATA + ':method', metatype),
167
+ getDesiredWorkerCount: Reflect.getMetadata(decorators_1.GET_DESIRED_WORKER_COUNT_METADATA + ':method', metatype),
168
+ onSpawnWorker: Reflect.getMetadata(decorators_1.ON_SPAWN_WORKER_METADATA + ':method', metatype),
169
+ onTerminateWorker: Reflect.getMetadata(decorators_1.ON_TERMINATE_WORKER_METADATA + ':method', metatype),
170
+ };
171
+ const scaler = {
172
+ entityType,
173
+ scalerInstance: instance,
174
+ options,
175
+ methods,
176
+ };
177
+ this.scalers.set(entityType, scaler);
178
+ this.logger.debug(`Registered scaler for entity type '${entityType}' with methods: ` +
179
+ Object.entries(methods)
180
+ .filter(([_, v]) => v)
181
+ .map(([k, _]) => k)
182
+ .join(', '));
183
+ }
184
+ /**
185
+ * Register scalers with CronManager for automatic scaling
186
+ */
187
+ async registerScalersWithCronManager() {
188
+ if (!this.cronManager) {
189
+ this.logger.warn('CronManager not available. Automatic scaling disabled.');
190
+ return;
191
+ }
192
+ for (const [entityType, scaler] of this.scalers) {
193
+ const processor = this.processors.get(entityType);
194
+ const scalingConfig = {
195
+ entityType,
196
+ maxWorkersPerEntity: scaler.options.maxWorkersPerEntity ?? 1,
197
+ getActiveEntityIds: async () => {
198
+ if (scaler.methods.getActiveEntities) {
199
+ return scaler.scalerInstance[scaler.methods.getActiveEntities]();
200
+ }
201
+ return [];
202
+ },
203
+ getDesiredWorkerCount: async (entityId) => {
204
+ if (scaler.methods.getDesiredWorkerCount) {
205
+ return scaler.scalerInstance[scaler.methods.getDesiredWorkerCount](entityId);
206
+ }
207
+ return 1; // Default to 1 worker
208
+ },
209
+ onSpawnWorker: async (entityId) => {
210
+ // First call custom spawn handler if defined
211
+ if (scaler.methods.onSpawnWorker) {
212
+ await scaler.scalerInstance[scaler.methods.onSpawnWorker](entityId);
213
+ }
214
+ // Auto-create worker if processor is registered
215
+ if (processor) {
216
+ await this.createWorkerForEntity(entityType, entityId);
217
+ }
218
+ },
219
+ onTerminateWorker: async (entityId, workerId) => {
220
+ // First call custom terminate handler if defined
221
+ if (scaler.methods.onTerminateWorker) {
222
+ await scaler.scalerInstance[scaler.methods.onTerminateWorker](entityId, workerId);
223
+ }
224
+ // Auto-terminate worker if processor is registered
225
+ if (processor) {
226
+ const workerName = processor.workerNameFn(entityId);
227
+ await this.workerManager.signalWorkerClose(workerName);
228
+ }
229
+ },
230
+ };
231
+ this.cronManager.registerEntityType(scalingConfig);
232
+ this.logger.log(`Registered scaling config for entity type '${entityType}'`);
233
+ }
234
+ }
235
+ /**
236
+ * Create a worker for an entity using the registered processor
237
+ */
238
+ async createWorkerForEntity(entityType, entityId) {
239
+ const processor = this.processors.get(entityType);
240
+ if (!processor) {
241
+ throw new Error(`No processor registered for entity type: ${entityType}`);
242
+ }
243
+ const workerName = processor.workerNameFn(entityId);
244
+ const queueName = processor.queueNameFn(entityId);
245
+ // Check if worker already exists
246
+ if (await this.workerManager.workerExists(workerName)) {
247
+ this.logger.debug(`Worker ${workerName} already exists, skipping`);
248
+ return;
249
+ }
250
+ this.logger.log(`Creating worker ${workerName} for ${entityType}:${entityId}`);
251
+ // Ensure queue exists
252
+ this.queueManager.getOrCreateQueue(queueName);
253
+ // Create the worker with the processor
254
+ const workerConfig = {
255
+ concurrency: 1,
256
+ stalledInterval: 1000,
257
+ lockDuration: 30000,
258
+ heartbeatTTL: 3,
259
+ heartbeatInterval: 1000,
260
+ ...this.config.workerDefaults,
261
+ ...processor.options.workerConfig,
262
+ };
263
+ await this.workerManager.createWorker({
264
+ workerName,
265
+ queueName,
266
+ config: workerConfig,
267
+ processor: async (job) => {
268
+ return this.processJob(processor, job, entityId);
269
+ },
270
+ events: {
271
+ onReady: async () => {
272
+ this.logger.log(`Worker ${workerName} ready`);
273
+ this.activeWorkers.get(entityType)?.add(entityId);
274
+ },
275
+ onCompleted: async (job) => {
276
+ this.logger.debug(`Worker ${workerName}: Job ${job.id} completed`);
277
+ },
278
+ onFailed: async (job, error) => {
279
+ this.logger.error(`Worker ${workerName}: Job ${job?.id} failed: ${error.message}`);
280
+ },
281
+ onClosed: async () => {
282
+ this.logger.log(`Worker ${workerName} closed`);
283
+ this.activeWorkers.get(entityType)?.delete(entityId);
284
+ },
285
+ },
286
+ });
287
+ }
288
+ /**
289
+ * Process a job using the registered handlers
290
+ */
291
+ async processJob(processor, job, entityId) {
292
+ const { processorInstance, jobHandlers, wildcardHandler } = processor;
293
+ const jobName = job.name;
294
+ // Try to find specific handler
295
+ const handler = jobHandlers.get(jobName);
296
+ if (handler) {
297
+ return processorInstance[handler.method](job, entityId);
298
+ }
299
+ // Fall back to wildcard handler
300
+ if (wildcardHandler) {
301
+ return processorInstance[wildcardHandler.method](job, entityId);
302
+ }
303
+ // No handler found
304
+ this.logger.warn(`No handler found for job '${jobName}' on entity type '${processor.entityType}'`);
305
+ return null;
306
+ }
307
+ // ==========================================================================
308
+ // PUBLIC API - Manual Registration
309
+ // ==========================================================================
310
+ /**
311
+ * Manually register a processor class
312
+ * Use this when auto-discovery is not available or for dynamic registration
313
+ */
314
+ async registerProcessorClass(processorClass, instance) {
315
+ const options = (0, decorators_1.getWorkerProcessorMetadata)(processorClass);
316
+ if (!options) {
317
+ throw new Error(`Class ${processorClass.name} is not decorated with @WorkerProcessor`);
318
+ }
319
+ const resolvedInstance = instance || this.moduleRef.get(processorClass, { strict: false });
320
+ this.registerProcessor(processorClass, resolvedInstance, options);
321
+ }
322
+ /**
323
+ * Manually register a scaler class
324
+ */
325
+ async registerScalerClass(scalerClass, instance) {
326
+ const options = (0, decorators_1.getEntityScalerMetadata)(scalerClass);
327
+ if (!options) {
328
+ throw new Error(`Class ${scalerClass.name} is not decorated with @EntityScaler`);
329
+ }
330
+ const resolvedInstance = instance || this.moduleRef.get(scalerClass, { strict: false });
331
+ this.registerScaler(scalerClass, resolvedInstance, options);
332
+ }
333
+ /**
334
+ * Get registered processor for an entity type
335
+ */
336
+ getProcessor(entityType) {
337
+ return this.processors.get(entityType);
338
+ }
339
+ /**
340
+ * Get registered scaler for an entity type
341
+ */
342
+ getScaler(entityType) {
343
+ return this.scalers.get(entityType);
344
+ }
345
+ /**
346
+ * Get all registered entity types
347
+ */
348
+ getRegisteredEntityTypes() {
349
+ return Array.from(new Set([...this.processors.keys(), ...this.scalers.keys()]));
350
+ }
351
+ /**
352
+ * Check if a worker exists for an entity
353
+ */
354
+ hasActiveWorker(entityType, entityId) {
355
+ return this.activeWorkers.get(entityType)?.has(entityId) ?? false;
356
+ }
357
+ /**
358
+ * Get all active workers for an entity type
359
+ */
360
+ getActiveWorkers(entityType) {
361
+ return Array.from(this.activeWorkers.get(entityType) || []);
362
+ }
363
+ };
364
+ exports.ProcessorDiscoveryService = ProcessorDiscoveryService;
365
+ exports.ProcessorDiscoveryService = ProcessorDiscoveryService = ProcessorDiscoveryService_1 = __decorate([
366
+ (0, common_1.Injectable)(),
367
+ __param(0, (0, common_1.Optional)()),
368
+ __param(1, (0, common_1.Optional)()),
369
+ __param(5, (0, common_1.Optional)()),
370
+ __param(6, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_CONFIG)),
371
+ __metadata("design:paramtypes", [core_1.DiscoveryService,
372
+ core_1.MetadataScanner,
373
+ core_1.ModuleRef,
374
+ worker_manager_1.WorkerManagerService,
375
+ queue_manager_1.QueueManagerService,
376
+ cron_manager_1.CronManagerService, Object])
377
+ ], ProcessorDiscoveryService);
378
+ //# sourceMappingURL=processor-discovery.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processor-discovery.service.js","sourceRoot":"","sources":["../../../src/services/processor-discovery/processor-discovery.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,uCAA4E;AAG5E,iDAc0B;AAE1B,sDAAyD;AACzD,oDAAuD;AACvD,kDAAqD;AACrD,4CAAoD;AA+BpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEI,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAMpC,YACc,gBAAmD,EACnD,eAAiD,EAC5C,SAAoB,EACpB,aAAmC,EACnC,YAAiC,EACtC,WAAgD,EAE5D,MAAkD;QAPrB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,oBAAe,GAAf,eAAe,CAAiB;QAC5C,cAAS,GAAT,SAAS,CAAW;QACpB,kBAAa,GAAb,aAAa,CAAsB;QACnC,iBAAY,GAAZ,YAAY,CAAqB;QACrB,gBAAW,GAAX,WAAW,CAAoB;QAE3C,WAAM,GAAN,MAAM,CAA2B;QAbnC,WAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;QACpD,eAAU,GAAqC,IAAI,GAAG,EAAE,CAAC;QACzD,YAAO,GAAkC,IAAI,GAAG,EAAE,CAAC;QACnD,kBAAa,GAA6B,IAAI,GAAG,EAAE,CAAC,CAAC,8CAA8C;IAWjH,CAAC;IAEJ,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,+DAA+D,CAChE,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,8BAA8B,EAAE,CA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@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atomic-queues",
3
- "version": "1.0.15",
3
+ "version": "1.1.0",
4
4
  "description": "A plug-and-play NestJS library for atomic process handling per entity with BullMQ, Redis distributed locking, and dynamic worker management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",