atomic-queues 1.2.1 → 1.2.2
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,8 +1,10 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
2
|
import { Job, JobsOptions } from 'bullmq';
|
|
3
3
|
import { QueueManagerService } from '../queue-manager/queue-manager.service';
|
|
4
|
+
import { WorkerProcessorOptions } from '../../decorators';
|
|
4
5
|
/**
|
|
5
6
|
* Options for QueueBus.execute()
|
|
7
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueue(command) instead
|
|
6
8
|
*/
|
|
7
9
|
export interface QueueBusExecuteOptions {
|
|
8
10
|
/**
|
|
@@ -16,6 +18,19 @@ export interface QueueBusExecuteOptions {
|
|
|
16
18
|
*/
|
|
17
19
|
jobOptions?: JobsOptions;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for .enqueue()
|
|
23
|
+
*/
|
|
24
|
+
export interface EnqueueOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Override the auto-extracted entityId
|
|
27
|
+
*/
|
|
28
|
+
entityId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* BullMQ job options (priority, delay, attempts, etc.)
|
|
31
|
+
*/
|
|
32
|
+
jobOptions?: JobsOptions;
|
|
33
|
+
}
|
|
19
34
|
/**
|
|
20
35
|
* Registry entry for a command/query class
|
|
21
36
|
*/
|
|
@@ -24,6 +39,53 @@ export interface CommandRegistryEntry {
|
|
|
24
39
|
targetClass: Type<any>;
|
|
25
40
|
isQuery: boolean;
|
|
26
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* QueueTarget - Fluent builder for targeting a specific processor's queue
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* await queueBus
|
|
47
|
+
* .forProcessor(TableWorkerProcessor)
|
|
48
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
49
|
+
*/
|
|
50
|
+
export declare class QueueTarget {
|
|
51
|
+
private readonly queueManager;
|
|
52
|
+
private readonly processorClass;
|
|
53
|
+
private readonly processorOptions;
|
|
54
|
+
private readonly logger;
|
|
55
|
+
constructor(queueManager: QueueManagerService, processorClass: Type<any>, processorOptions: WorkerProcessorOptions);
|
|
56
|
+
/**
|
|
57
|
+
* Get the queue name function from the processor
|
|
58
|
+
*/
|
|
59
|
+
private getQueueNameFn;
|
|
60
|
+
/**
|
|
61
|
+
* Enqueue a command/query for processing
|
|
62
|
+
*
|
|
63
|
+
* @param commandOrQuery - The command or query instance
|
|
64
|
+
* @param options - Optional settings (entityId override, jobOptions)
|
|
65
|
+
* @returns The created BullMQ job
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* await queueBus
|
|
69
|
+
* .forProcessor(TableWorkerProcessor)
|
|
70
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
71
|
+
*
|
|
72
|
+
* // With job options
|
|
73
|
+
* await queueBus
|
|
74
|
+
* .forProcessor(TableWorkerProcessor)
|
|
75
|
+
* .enqueue(new DealCommand(tableId), { jobOptions: { delay: 5000 } });
|
|
76
|
+
*/
|
|
77
|
+
enqueue<T extends object>(commandOrQuery: T, options?: EnqueueOptions): Promise<Job>;
|
|
78
|
+
/**
|
|
79
|
+
* Enqueue and wait for result
|
|
80
|
+
*/
|
|
81
|
+
enqueueAndWait<T extends object, R = any>(commandOrQuery: T, options?: EnqueueOptions & {
|
|
82
|
+
timeout?: number;
|
|
83
|
+
}): Promise<R>;
|
|
84
|
+
/**
|
|
85
|
+
* Enqueue multiple commands/queries in bulk
|
|
86
|
+
*/
|
|
87
|
+
enqueueBulk<T extends object>(commandsOrQueries: T[], options?: EnqueueOptions): Promise<Job[]>;
|
|
88
|
+
}
|
|
27
89
|
/**
|
|
28
90
|
* QueueBus
|
|
29
91
|
*
|
|
@@ -36,32 +98,34 @@ export interface CommandRegistryEntry {
|
|
|
36
98
|
* - Job name = class name (MakeBetCommand)
|
|
37
99
|
* - Worker looks up class by name and instantiates from job.data
|
|
38
100
|
* - Works with @nestjs/cqrs CommandBus/QueryBus on worker side
|
|
101
|
+
* - Fluent API: queueBus.forProcessor(Processor).enqueue(command)
|
|
39
102
|
*
|
|
40
103
|
* @example
|
|
41
104
|
* ```typescript
|
|
42
|
-
* //
|
|
43
|
-
* await this.queueBus
|
|
44
|
-
*
|
|
45
|
-
* new MakeBetCommand(tableId,
|
|
46
|
-
* );
|
|
105
|
+
* // Fluent API (recommended)
|
|
106
|
+
* await this.queueBus
|
|
107
|
+
* .forProcessor(TableWorkerProcessor)
|
|
108
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
47
109
|
*
|
|
48
|
-
* //
|
|
49
|
-
* await this.queueBus
|
|
50
|
-
*
|
|
51
|
-
* new
|
|
52
|
-
* { entityId: tableId }
|
|
53
|
-
* );
|
|
110
|
+
* // With job options
|
|
111
|
+
* await this.queueBus
|
|
112
|
+
* .forProcessor(TableWorkerProcessor)
|
|
113
|
+
* .enqueue(new DealCommand(tableId), { jobOptions: { delay: 5000 } });
|
|
54
114
|
*
|
|
55
115
|
* // Worker side (automatic):
|
|
56
|
-
* // 1. Job arrives: { name: 'MakeBetCommand', data: { tableId,
|
|
57
|
-
* // 2. Worker looks up MakeBetCommand class
|
|
58
|
-
* // 3. Instantiates with
|
|
116
|
+
* // 1. Job arrives: { name: 'MakeBetCommand', data: { tableId, bets, player } }
|
|
117
|
+
* // 2. Worker looks up MakeBetCommand class in QueueBus registry
|
|
118
|
+
* // 3. Instantiates with entityId + data
|
|
59
119
|
* // 4. Executes via CommandBus
|
|
60
120
|
* ```
|
|
61
121
|
*/
|
|
62
122
|
export declare class QueueBus {
|
|
63
123
|
private readonly queueManager;
|
|
64
124
|
private readonly logger;
|
|
125
|
+
/**
|
|
126
|
+
* Cache of processor options by class
|
|
127
|
+
*/
|
|
128
|
+
private readonly processorCache;
|
|
65
129
|
/**
|
|
66
130
|
* Global registry of command/query classes
|
|
67
131
|
* Key: class name (e.g., 'MakeBetCommand')
|
|
@@ -69,6 +133,18 @@ export declare class QueueBus {
|
|
|
69
133
|
*/
|
|
70
134
|
private static readonly globalRegistry;
|
|
71
135
|
constructor(queueManager: QueueManagerService);
|
|
136
|
+
/**
|
|
137
|
+
* Target a specific processor's queue for enqueueing commands
|
|
138
|
+
*
|
|
139
|
+
* @param processorClass - The @WorkerProcessor decorated class
|
|
140
|
+
* @returns QueueTarget builder for fluent API
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* await this.queueBus
|
|
144
|
+
* .forProcessor(TableWorkerProcessor)
|
|
145
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
146
|
+
*/
|
|
147
|
+
forProcessor(processorClass: Type<any>): QueueTarget;
|
|
72
148
|
/**
|
|
73
149
|
* Register a command class for worker-side instantiation
|
|
74
150
|
*
|
|
@@ -100,44 +176,32 @@ export declare class QueueBus {
|
|
|
100
176
|
/**
|
|
101
177
|
* Execute a command/query by adding it to a queue
|
|
102
178
|
*
|
|
179
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueue(command) instead
|
|
180
|
+
*
|
|
103
181
|
* @param queuePattern - Queue name pattern with {entityId} placeholder
|
|
104
182
|
* @param commandOrQuery - The command/query instance to execute
|
|
105
183
|
* @param options - Optional settings (entityId, jobOptions)
|
|
106
184
|
* @returns The created BullMQ job
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* // Pattern with placeholder
|
|
110
|
-
* await queueBus.execute(
|
|
111
|
-
* 'table-worker-{entityId}',
|
|
112
|
-
* new MakeBetCommand(tableId, sessionId, amount),
|
|
113
|
-
* );
|
|
114
|
-
*
|
|
115
|
-
* // Static queue name (no placeholder)
|
|
116
|
-
* await queueBus.execute(
|
|
117
|
-
* 'payment-queue',
|
|
118
|
-
* new ProcessPaymentCommand(paymentId, amount),
|
|
119
|
-
* );
|
|
120
185
|
*/
|
|
121
186
|
execute<T extends object>(queuePattern: string, commandOrQuery: T, options?: QueueBusExecuteOptions): Promise<Job>;
|
|
122
187
|
/**
|
|
123
188
|
* Execute and wait for result (if supported by worker)
|
|
124
189
|
* Uses BullMQ's waitUntilFinished
|
|
190
|
+
*
|
|
191
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueueAndWait(command) instead
|
|
125
192
|
*/
|
|
126
193
|
executeAndWait<T extends object, R = any>(queuePattern: string, commandOrQuery: T, options?: QueueBusExecuteOptions & {
|
|
127
194
|
timeout?: number;
|
|
128
195
|
}): Promise<R>;
|
|
129
196
|
/**
|
|
130
197
|
* Add multiple commands/queries to the same queue in bulk
|
|
198
|
+
*
|
|
199
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueueBulk(commands) instead
|
|
131
200
|
*/
|
|
132
201
|
executeBulk<T extends object>(queuePattern: string, commandsOrQueries: T[], options?: QueueBusExecuteOptions): Promise<Job[]>;
|
|
133
202
|
/**
|
|
134
203
|
* Resolve queue name by replacing {entityId} placeholder
|
|
135
204
|
*/
|
|
136
205
|
private resolveQueueName;
|
|
137
|
-
/**
|
|
138
|
-
* Extract entityId from command data
|
|
139
|
-
* Tries common property names in order
|
|
140
|
-
*/
|
|
141
|
-
private extractEntityId;
|
|
142
206
|
}
|
|
143
207
|
//# sourceMappingURL=queue-bus.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-bus.service.d.ts","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-bus.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"queue-bus.service.d.ts","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-bus.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MA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,EAAE,sBAAsB,GAC/B,OAAO,CAAC,GAAG,CAAC;IAmBf;;;;;OAKG;IACG,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,GAAG,EAC5C,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,CAAC,EACjB,OAAO,CAAC,EAAE,sBAAsB,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACtD,OAAO,CAAC,CAAC,CAAC;IAab;;;;OAIG;IACG,WAAW,CAAC,CAAC,SAAS,MAAM,EAChC,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,CAAC,EAAE,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,GAAG,EAAE,CAAC;IAmBjB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAGzB"}
|
|
@@ -10,9 +10,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
var QueueBus_1;
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.QueueBus = void 0;
|
|
13
|
+
exports.QueueBus = exports.QueueTarget = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const queue_manager_service_1 = require("../queue-manager/queue-manager.service");
|
|
16
|
+
const decorators_1 = require("../../decorators");
|
|
16
17
|
/**
|
|
17
18
|
* Derive job name from class name
|
|
18
19
|
* MakeBetCommand -> MakeBetCommand (keep as-is for lookup)
|
|
@@ -31,6 +32,115 @@ function extractData(commandOrQuery) {
|
|
|
31
32
|
}
|
|
32
33
|
return data;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Extract entityId from command data
|
|
37
|
+
* Tries common property names in order
|
|
38
|
+
*/
|
|
39
|
+
function extractEntityId(data, logger) {
|
|
40
|
+
const candidates = ['entityId', 'tableId', 'userId', 'id', 'gameId', 'playerId'];
|
|
41
|
+
for (const key of candidates) {
|
|
42
|
+
if (data[key] !== undefined && data[key] !== null) {
|
|
43
|
+
return String(data[key]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Log warning if no entityId found
|
|
47
|
+
logger?.warn(`Could not extract entityId from command data. Keys: ${Object.keys(data).join(', ')}`);
|
|
48
|
+
return 'default';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* QueueTarget - Fluent builder for targeting a specific processor's queue
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* await queueBus
|
|
55
|
+
* .forProcessor(TableWorkerProcessor)
|
|
56
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
57
|
+
*/
|
|
58
|
+
class QueueTarget {
|
|
59
|
+
constructor(queueManager, processorClass, processorOptions) {
|
|
60
|
+
this.queueManager = queueManager;
|
|
61
|
+
this.processorClass = processorClass;
|
|
62
|
+
this.processorOptions = processorOptions;
|
|
63
|
+
this.logger = new common_1.Logger(QueueTarget.name);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get the queue name function from the processor
|
|
67
|
+
*/
|
|
68
|
+
getQueueNameFn() {
|
|
69
|
+
const { queueName } = this.processorOptions;
|
|
70
|
+
if (typeof queueName === 'function') {
|
|
71
|
+
return queueName;
|
|
72
|
+
}
|
|
73
|
+
if (typeof queueName === 'string') {
|
|
74
|
+
// Static queue name or pattern with {entityId}
|
|
75
|
+
return (entityId) => queueName.replace('{entityId}', entityId);
|
|
76
|
+
}
|
|
77
|
+
// Default: entityType-{entityId}-queue
|
|
78
|
+
const { entityType } = this.processorOptions;
|
|
79
|
+
return (entityId) => `${entityType}-${entityId}-queue`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Enqueue a command/query for processing
|
|
83
|
+
*
|
|
84
|
+
* @param commandOrQuery - The command or query instance
|
|
85
|
+
* @param options - Optional settings (entityId override, jobOptions)
|
|
86
|
+
* @returns The created BullMQ job
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* await queueBus
|
|
90
|
+
* .forProcessor(TableWorkerProcessor)
|
|
91
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
92
|
+
*
|
|
93
|
+
* // With job options
|
|
94
|
+
* await queueBus
|
|
95
|
+
* .forProcessor(TableWorkerProcessor)
|
|
96
|
+
* .enqueue(new DealCommand(tableId), { jobOptions: { delay: 5000 } });
|
|
97
|
+
*/
|
|
98
|
+
async enqueue(commandOrQuery, options) {
|
|
99
|
+
const jobName = getJobName(commandOrQuery);
|
|
100
|
+
const data = extractData(commandOrQuery);
|
|
101
|
+
const entityId = options?.entityId ?? extractEntityId(data, this.logger);
|
|
102
|
+
// Get queue name from processor's queueName function
|
|
103
|
+
const queueNameFn = this.getQueueNameFn();
|
|
104
|
+
const queueName = queueNameFn(entityId);
|
|
105
|
+
// Get or create the queue
|
|
106
|
+
const queue = this.queueManager.getOrCreateQueue(queueName);
|
|
107
|
+
this.logger.debug(`[${this.processorClass.name}] Adding job ${jobName} to queue ${queueName}`);
|
|
108
|
+
// Add job to queue
|
|
109
|
+
return queue.add(jobName, data, options?.jobOptions);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Enqueue and wait for result
|
|
113
|
+
*/
|
|
114
|
+
async enqueueAndWait(commandOrQuery, options) {
|
|
115
|
+
const job = await this.enqueue(commandOrQuery, options);
|
|
116
|
+
const data = extractData(commandOrQuery);
|
|
117
|
+
const entityId = options?.entityId ?? extractEntityId(data, this.logger);
|
|
118
|
+
const queueNameFn = this.getQueueNameFn();
|
|
119
|
+
const queueName = queueNameFn(entityId);
|
|
120
|
+
const queueEvents = await this.queueManager.getQueueEvents(queueName);
|
|
121
|
+
return job.waitUntilFinished(queueEvents, options?.timeout);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Enqueue multiple commands/queries in bulk
|
|
125
|
+
*/
|
|
126
|
+
async enqueueBulk(commandsOrQueries, options) {
|
|
127
|
+
if (commandsOrQueries.length === 0)
|
|
128
|
+
return [];
|
|
129
|
+
const firstData = extractData(commandsOrQueries[0]);
|
|
130
|
+
const entityId = options?.entityId ?? extractEntityId(firstData, this.logger);
|
|
131
|
+
const queueNameFn = this.getQueueNameFn();
|
|
132
|
+
const queueName = queueNameFn(entityId);
|
|
133
|
+
const queue = this.queueManager.getOrCreateQueue(queueName);
|
|
134
|
+
const bulkJobs = commandsOrQueries.map((cmd) => ({
|
|
135
|
+
name: getJobName(cmd),
|
|
136
|
+
data: extractData(cmd),
|
|
137
|
+
opts: options?.jobOptions,
|
|
138
|
+
}));
|
|
139
|
+
this.logger.debug(`[${this.processorClass.name}] Adding ${bulkJobs.length} jobs to queue ${queueName}`);
|
|
140
|
+
return queue.addBulk(bulkJobs);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.QueueTarget = QueueTarget;
|
|
34
144
|
/**
|
|
35
145
|
* QueueBus
|
|
36
146
|
*
|
|
@@ -43,26 +153,24 @@ function extractData(commandOrQuery) {
|
|
|
43
153
|
* - Job name = class name (MakeBetCommand)
|
|
44
154
|
* - Worker looks up class by name and instantiates from job.data
|
|
45
155
|
* - Works with @nestjs/cqrs CommandBus/QueryBus on worker side
|
|
156
|
+
* - Fluent API: queueBus.forProcessor(Processor).enqueue(command)
|
|
46
157
|
*
|
|
47
158
|
* @example
|
|
48
159
|
* ```typescript
|
|
49
|
-
* //
|
|
50
|
-
* await this.queueBus
|
|
51
|
-
*
|
|
52
|
-
* new MakeBetCommand(tableId,
|
|
53
|
-
* );
|
|
160
|
+
* // Fluent API (recommended)
|
|
161
|
+
* await this.queueBus
|
|
162
|
+
* .forProcessor(TableWorkerProcessor)
|
|
163
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
54
164
|
*
|
|
55
|
-
* //
|
|
56
|
-
* await this.queueBus
|
|
57
|
-
*
|
|
58
|
-
* new
|
|
59
|
-
* { entityId: tableId }
|
|
60
|
-
* );
|
|
165
|
+
* // With job options
|
|
166
|
+
* await this.queueBus
|
|
167
|
+
* .forProcessor(TableWorkerProcessor)
|
|
168
|
+
* .enqueue(new DealCommand(tableId), { jobOptions: { delay: 5000 } });
|
|
61
169
|
*
|
|
62
170
|
* // Worker side (automatic):
|
|
63
|
-
* // 1. Job arrives: { name: 'MakeBetCommand', data: { tableId,
|
|
64
|
-
* // 2. Worker looks up MakeBetCommand class
|
|
65
|
-
* // 3. Instantiates with
|
|
171
|
+
* // 1. Job arrives: { name: 'MakeBetCommand', data: { tableId, bets, player } }
|
|
172
|
+
* // 2. Worker looks up MakeBetCommand class in QueueBus registry
|
|
173
|
+
* // 3. Instantiates with entityId + data
|
|
66
174
|
* // 4. Executes via CommandBus
|
|
67
175
|
* ```
|
|
68
176
|
*/
|
|
@@ -70,6 +178,36 @@ let QueueBus = QueueBus_1 = class QueueBus {
|
|
|
70
178
|
constructor(queueManager) {
|
|
71
179
|
this.queueManager = queueManager;
|
|
72
180
|
this.logger = new common_1.Logger(QueueBus_1.name);
|
|
181
|
+
/**
|
|
182
|
+
* Cache of processor options by class
|
|
183
|
+
*/
|
|
184
|
+
this.processorCache = new Map();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Target a specific processor's queue for enqueueing commands
|
|
188
|
+
*
|
|
189
|
+
* @param processorClass - The @WorkerProcessor decorated class
|
|
190
|
+
* @returns QueueTarget builder for fluent API
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* await this.queueBus
|
|
194
|
+
* .forProcessor(TableWorkerProcessor)
|
|
195
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
196
|
+
*/
|
|
197
|
+
forProcessor(processorClass) {
|
|
198
|
+
// Check cache first
|
|
199
|
+
let options = this.processorCache.get(processorClass);
|
|
200
|
+
if (!options) {
|
|
201
|
+
// Get metadata from @WorkerProcessor decorator
|
|
202
|
+
options = (0, decorators_1.getWorkerProcessorMetadata)(processorClass);
|
|
203
|
+
if (!options) {
|
|
204
|
+
throw new Error(`Class ${processorClass.name} is not decorated with @WorkerProcessor. ` +
|
|
205
|
+
`Cannot determine queue configuration.`);
|
|
206
|
+
}
|
|
207
|
+
// Cache for future use
|
|
208
|
+
this.processorCache.set(processorClass, options);
|
|
209
|
+
}
|
|
210
|
+
return new QueueTarget(this.queueManager, processorClass, options);
|
|
73
211
|
}
|
|
74
212
|
/**
|
|
75
213
|
* Register a command class for worker-side instantiation
|
|
@@ -123,28 +261,17 @@ let QueueBus = QueueBus_1 = class QueueBus {
|
|
|
123
261
|
/**
|
|
124
262
|
* Execute a command/query by adding it to a queue
|
|
125
263
|
*
|
|
264
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueue(command) instead
|
|
265
|
+
*
|
|
126
266
|
* @param queuePattern - Queue name pattern with {entityId} placeholder
|
|
127
267
|
* @param commandOrQuery - The command/query instance to execute
|
|
128
268
|
* @param options - Optional settings (entityId, jobOptions)
|
|
129
269
|
* @returns The created BullMQ job
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* // Pattern with placeholder
|
|
133
|
-
* await queueBus.execute(
|
|
134
|
-
* 'table-worker-{entityId}',
|
|
135
|
-
* new MakeBetCommand(tableId, sessionId, amount),
|
|
136
|
-
* );
|
|
137
|
-
*
|
|
138
|
-
* // Static queue name (no placeholder)
|
|
139
|
-
* await queueBus.execute(
|
|
140
|
-
* 'payment-queue',
|
|
141
|
-
* new ProcessPaymentCommand(paymentId, amount),
|
|
142
|
-
* );
|
|
143
270
|
*/
|
|
144
271
|
async execute(queuePattern, commandOrQuery, options) {
|
|
145
272
|
const jobName = getJobName(commandOrQuery);
|
|
146
273
|
const data = extractData(commandOrQuery);
|
|
147
|
-
const entityId = options?.entityId ??
|
|
274
|
+
const entityId = options?.entityId ?? extractEntityId(data, this.logger);
|
|
148
275
|
// Resolve queue name with entityId
|
|
149
276
|
const queueName = this.resolveQueueName(queuePattern, entityId);
|
|
150
277
|
// Get or create the queue
|
|
@@ -156,19 +283,23 @@ let QueueBus = QueueBus_1 = class QueueBus {
|
|
|
156
283
|
/**
|
|
157
284
|
* Execute and wait for result (if supported by worker)
|
|
158
285
|
* Uses BullMQ's waitUntilFinished
|
|
286
|
+
*
|
|
287
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueueAndWait(command) instead
|
|
159
288
|
*/
|
|
160
289
|
async executeAndWait(queuePattern, commandOrQuery, options) {
|
|
161
290
|
const job = await this.execute(queuePattern, commandOrQuery, options);
|
|
162
|
-
const queueEvents = await this.queueManager.getQueueEvents(this.resolveQueueName(queuePattern, options?.entityId ??
|
|
291
|
+
const queueEvents = await this.queueManager.getQueueEvents(this.resolveQueueName(queuePattern, options?.entityId ?? extractEntityId(extractData(commandOrQuery), this.logger)));
|
|
163
292
|
return job.waitUntilFinished(queueEvents, options?.timeout);
|
|
164
293
|
}
|
|
165
294
|
/**
|
|
166
295
|
* Add multiple commands/queries to the same queue in bulk
|
|
296
|
+
*
|
|
297
|
+
* @deprecated Use .forProcessor(ProcessorClass).enqueueBulk(commands) instead
|
|
167
298
|
*/
|
|
168
299
|
async executeBulk(queuePattern, commandsOrQueries, options) {
|
|
169
300
|
if (commandsOrQueries.length === 0)
|
|
170
301
|
return [];
|
|
171
|
-
const entityId = options?.entityId ??
|
|
302
|
+
const entityId = options?.entityId ?? extractEntityId(extractData(commandsOrQueries[0]), this.logger);
|
|
172
303
|
const queueName = this.resolveQueueName(queuePattern, entityId);
|
|
173
304
|
const queue = this.queueManager.getOrCreateQueue(queueName);
|
|
174
305
|
const bulkJobs = commandsOrQueries.map((cmd) => ({
|
|
@@ -184,21 +315,6 @@ let QueueBus = QueueBus_1 = class QueueBus {
|
|
|
184
315
|
resolveQueueName(pattern, entityId) {
|
|
185
316
|
return pattern.replace('{entityId}', entityId);
|
|
186
317
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Extract entityId from command data
|
|
189
|
-
* Tries common property names in order
|
|
190
|
-
*/
|
|
191
|
-
extractEntityId(data) {
|
|
192
|
-
const candidates = ['entityId', 'tableId', 'userId', 'id', 'gameId', 'playerId'];
|
|
193
|
-
for (const key of candidates) {
|
|
194
|
-
if (data[key] !== undefined && data[key] !== null) {
|
|
195
|
-
return String(data[key]);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// Log warning if no entityId found
|
|
199
|
-
this.logger.warn(`Could not extract entityId from command data. Keys: ${Object.keys(data).join(', ')}`);
|
|
200
|
-
return 'default';
|
|
201
|
-
}
|
|
202
318
|
};
|
|
203
319
|
exports.QueueBus = QueueBus;
|
|
204
320
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-bus.service.js","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-bus.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA0D;AAE1D,kFAA6E;
|
|
1
|
+
{"version":3,"file":"queue-bus.service.js","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-bus.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA0D;AAE1D,kFAA6E;AAC7E,iDAAsF;AAEtF;;;GAGG;AACH,SAAS,UAAU,CAAC,cAAsB;IACxC,OAAO,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,cAAsB;IACzC,MAAM,IAAI,GAAwB,EAAE,CAAC;IAErC,gCAAgC;IAChC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,GAAI,cAAsB,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAyB,EAAE,MAAe;IACjE,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEjF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC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,CAAC,CAAC;IACjD,CAAC;;AApMU,4BAAQ;AAQnB;;;;GAIG;AACqB,uBAAc,GAAG,IAAI,GAAG,EAAgC,AAA1C,CAA2C;mBAbtE,QAAQ;IADpB,IAAA,mBAAU,GAAE;qCAiBsB,2CAAmB;GAhBzC,QAAQ,CAqMpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atomic-queues",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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",
|