atomic-queues 1.4.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +300 -283
- package/dist/decorators/constants.d.ts +17 -0
- package/dist/decorators/constants.d.ts.map +1 -0
- package/dist/decorators/constants.js +23 -0
- package/dist/decorators/constants.js.map +1 -0
- package/dist/decorators/entity.decorators.d.ts +88 -0
- package/dist/decorators/entity.decorators.d.ts.map +1 -0
- package/dist/decorators/entity.decorators.js +150 -0
- package/dist/decorators/entity.decorators.js.map +1 -0
- package/dist/decorators/index.d.ts +9 -1
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +9 -1
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/interfaces.d.ts +130 -0
- package/dist/decorators/interfaces.d.ts.map +1 -0
- package/dist/decorators/interfaces.js +3 -0
- package/dist/decorators/interfaces.js.map +1 -0
- package/dist/decorators/job.decorators.d.ts +60 -0
- package/dist/decorators/job.decorators.d.ts.map +1 -0
- package/dist/decorators/job.decorators.js +97 -0
- package/dist/decorators/job.decorators.js.map +1 -0
- package/dist/decorators/legacy.decorators.d.ts +36 -0
- package/dist/decorators/legacy.decorators.d.ts.map +1 -0
- package/dist/decorators/legacy.decorators.js +61 -0
- package/dist/decorators/legacy.decorators.js.map +1 -0
- package/dist/decorators/metadata-readers.d.ts +31 -0
- package/dist/decorators/metadata-readers.d.ts.map +1 -0
- package/dist/decorators/metadata-readers.js +53 -0
- package/dist/decorators/metadata-readers.js.map +1 -0
- package/dist/decorators/registry.d.ts +2 -0
- package/dist/decorators/registry.d.ts.map +1 -0
- package/dist/decorators/registry.js +6 -0
- package/dist/decorators/registry.js.map +1 -0
- package/dist/decorators/scaler.decorators.d.ts +65 -0
- package/dist/decorators/scaler.decorators.d.ts.map +1 -0
- package/dist/decorators/scaler.decorators.js +103 -0
- package/dist/decorators/scaler.decorators.js.map +1 -0
- package/dist/decorators/type-guards.d.ts +18 -0
- package/dist/decorators/type-guards.d.ts.map +1 -0
- package/dist/decorators/type-guards.js +32 -0
- package/dist/decorators/type-guards.js.map +1 -0
- package/dist/decorators/utils.d.ts +20 -0
- package/dist/decorators/utils.d.ts.map +1 -0
- package/dist/decorators/utils.js +98 -0
- package/dist/decorators/utils.js.map +1 -0
- package/dist/decorators/worker.decorators.d.ts +58 -0
- package/dist/decorators/worker.decorators.d.ts.map +1 -0
- package/dist/decorators/worker.decorators.js +92 -0
- package/dist/decorators/worker.decorators.js.map +1 -0
- package/dist/domain/interfaces/config.interfaces.d.ts +188 -0
- package/dist/domain/interfaces/config.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/config.interfaces.js +3 -0
- package/dist/domain/interfaces/config.interfaces.js.map +1 -0
- package/dist/domain/interfaces/cqrs.interfaces.d.ts +7 -0
- package/dist/domain/interfaces/cqrs.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/cqrs.interfaces.js +3 -0
- package/dist/domain/interfaces/cqrs.interfaces.js.map +1 -0
- package/dist/domain/interfaces/event.interfaces.d.ts +71 -0
- package/dist/domain/interfaces/event.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/event.interfaces.js +3 -0
- package/dist/domain/interfaces/event.interfaces.js.map +1 -0
- package/dist/domain/interfaces/index-tracking.interfaces.d.ts +69 -0
- package/dist/domain/interfaces/index-tracking.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/index-tracking.interfaces.js +3 -0
- package/dist/domain/interfaces/index-tracking.interfaces.js.map +1 -0
- package/dist/domain/interfaces/index.d.ts +12 -0
- package/dist/domain/interfaces/index.d.ts.map +1 -0
- package/dist/domain/interfaces/index.js +28 -0
- package/dist/domain/interfaces/index.js.map +1 -0
- package/dist/domain/interfaces/job.interfaces.d.ts +76 -0
- package/dist/domain/interfaces/job.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/job.interfaces.js +3 -0
- package/dist/domain/interfaces/job.interfaces.js.map +1 -0
- package/dist/domain/interfaces/lock.interfaces.d.ts +54 -0
- package/dist/domain/interfaces/lock.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/lock.interfaces.js +3 -0
- package/dist/domain/interfaces/lock.interfaces.js.map +1 -0
- package/dist/domain/interfaces/process.interfaces.d.ts +44 -0
- package/dist/domain/interfaces/process.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/process.interfaces.js +3 -0
- package/dist/domain/interfaces/process.interfaces.js.map +1 -0
- package/dist/domain/interfaces/queue.interfaces.d.ts +46 -0
- package/dist/domain/interfaces/queue.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/queue.interfaces.js +3 -0
- package/dist/domain/interfaces/queue.interfaces.js.map +1 -0
- package/dist/domain/interfaces/scaling.interfaces.d.ts +62 -0
- package/dist/domain/interfaces/scaling.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/scaling.interfaces.js +3 -0
- package/dist/domain/interfaces/scaling.interfaces.js.map +1 -0
- package/dist/domain/interfaces/utility.types.d.ts +15 -0
- package/dist/domain/interfaces/utility.types.d.ts.map +1 -0
- package/dist/domain/interfaces/utility.types.js +3 -0
- package/dist/domain/interfaces/utility.types.js.map +1 -0
- package/dist/domain/interfaces/worker.interfaces.d.ts +120 -0
- package/dist/domain/interfaces/worker.interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces/worker.interfaces.js +3 -0
- package/dist/domain/interfaces/worker.interfaces.js.map +1 -0
- package/dist/module/atomic-queues.module.d.ts.map +1 -1
- package/dist/module/atomic-queues.module.js +5 -0
- package/dist/module/atomic-queues.module.js.map +1 -1
- package/dist/services/cron-manager/cron-manager.service.d.ts +5 -4
- package/dist/services/cron-manager/cron-manager.service.d.ts.map +1 -1
- package/dist/services/cron-manager/cron-manager.service.js +26 -57
- package/dist/services/cron-manager/cron-manager.service.js.map +1 -1
- package/dist/services/index-manager/index-manager.service.d.ts +0 -4
- package/dist/services/index-manager/index-manager.service.d.ts.map +1 -1
- package/dist/services/index-manager/index-manager.service.js +4 -16
- package/dist/services/index-manager/index-manager.service.js.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/processor-discovery/decorator-discovery.service.d.ts +40 -0
- package/dist/services/processor-discovery/decorator-discovery.service.d.ts.map +1 -0
- package/dist/services/processor-discovery/decorator-discovery.service.js +191 -0
- package/dist/services/processor-discovery/decorator-discovery.service.js.map +1 -0
- package/dist/services/processor-discovery/index.d.ts +4 -0
- package/dist/services/processor-discovery/index.d.ts.map +1 -1
- package/dist/services/processor-discovery/index.js +4 -0
- package/dist/services/processor-discovery/index.js.map +1 -1
- package/dist/services/processor-discovery/processor-discovery.service.d.ts +30 -138
- package/dist/services/processor-discovery/processor-discovery.service.d.ts.map +1 -1
- package/dist/services/processor-discovery/processor-discovery.service.js +125 -502
- package/dist/services/processor-discovery/processor-discovery.service.js.map +1 -1
- package/dist/services/processor-discovery/processor-registry.d.ts +58 -0
- package/dist/services/processor-discovery/processor-registry.d.ts.map +1 -0
- package/dist/services/processor-discovery/processor-registry.js +74 -0
- package/dist/services/processor-discovery/processor-registry.js.map +1 -0
- package/dist/services/processor-discovery/scaling-registration.service.d.ts +60 -0
- package/dist/services/processor-discovery/scaling-registration.service.d.ts.map +1 -0
- package/dist/services/processor-discovery/scaling-registration.service.js +261 -0
- package/dist/services/processor-discovery/scaling-registration.service.js.map +1 -0
- package/dist/services/processor-discovery/worker-factory.service.d.ts +54 -0
- package/dist/services/processor-discovery/worker-factory.service.d.ts.map +1 -0
- package/dist/services/processor-discovery/worker-factory.service.js +185 -0
- package/dist/services/processor-discovery/worker-factory.service.js.map +1 -0
- package/dist/services/queue-bus/entity-target.d.ts +58 -0
- package/dist/services/queue-bus/entity-target.d.ts.map +1 -0
- package/dist/services/queue-bus/entity-target.js +109 -0
- package/dist/services/queue-bus/entity-target.js.map +1 -0
- package/dist/services/queue-bus/index.d.ts +4 -0
- package/dist/services/queue-bus/index.d.ts.map +1 -1
- package/dist/services/queue-bus/index.js +4 -0
- package/dist/services/queue-bus/index.js.map +1 -1
- package/dist/services/queue-bus/queue-bus.service.d.ts +9 -145
- package/dist/services/queue-bus/queue-bus.service.d.ts.map +1 -1
- package/dist/services/queue-bus/queue-bus.service.js +23 -311
- package/dist/services/queue-bus/queue-bus.service.js.map +1 -1
- package/dist/services/queue-bus/queue-bus.types.d.ts +40 -0
- package/dist/services/queue-bus/queue-bus.types.d.ts.map +1 -0
- package/dist/services/queue-bus/queue-bus.types.js +3 -0
- package/dist/services/queue-bus/queue-bus.types.js.map +1 -0
- package/dist/services/queue-bus/queue-bus.utils.d.ts +34 -0
- package/dist/services/queue-bus/queue-bus.utils.d.ts.map +1 -0
- package/dist/services/queue-bus/queue-bus.utils.js +82 -0
- package/dist/services/queue-bus/queue-bus.utils.js.map +1 -0
- package/dist/services/queue-bus/queue-target.d.ts +61 -0
- package/dist/services/queue-bus/queue-target.d.ts.map +1 -0
- package/dist/services/queue-bus/queue-target.js +123 -0
- package/dist/services/queue-bus/queue-target.js.map +1 -0
- package/dist/services/queue-events-manager/queue-events-manager.service.d.ts +23 -6
- package/dist/services/queue-events-manager/queue-events-manager.service.d.ts.map +1 -1
- package/dist/services/queue-events-manager/queue-events-manager.service.js +69 -37
- package/dist/services/queue-events-manager/queue-events-manager.service.js.map +1 -1
- package/dist/services/resource-lock/resource-lock.service.d.ts +0 -4
- package/dist/services/resource-lock/resource-lock.service.d.ts.map +1 -1
- package/dist/services/resource-lock/resource-lock.service.js +4 -16
- package/dist/services/resource-lock/resource-lock.service.js.map +1 -1
- package/dist/services/service-queue/index.d.ts +1 -0
- package/dist/services/service-queue/index.d.ts.map +1 -1
- package/dist/services/service-queue/index.js +1 -0
- package/dist/services/service-queue/index.js.map +1 -1
- package/dist/services/service-queue/service-queue.service.d.ts +2 -35
- package/dist/services/service-queue/service-queue.service.d.ts.map +1 -1
- package/dist/services/service-queue/service-queue.service.js +17 -49
- package/dist/services/service-queue/service-queue.service.js.map +1 -1
- package/dist/services/service-queue/service-queue.types.d.ts +32 -0
- package/dist/services/service-queue/service-queue.types.d.ts.map +1 -0
- package/dist/services/service-queue/service-queue.types.js +27 -0
- package/dist/services/service-queue/service-queue.types.js.map +1 -0
- package/dist/services/spawn-queue/index.d.ts +2 -0
- package/dist/services/spawn-queue/index.d.ts.map +1 -0
- package/dist/services/spawn-queue/index.js +18 -0
- package/dist/services/spawn-queue/index.js.map +1 -0
- package/dist/services/spawn-queue/spawn-queue.service.d.ts +119 -0
- package/dist/services/spawn-queue/spawn-queue.service.d.ts.map +1 -0
- package/dist/services/spawn-queue/spawn-queue.service.js +273 -0
- package/dist/services/spawn-queue/spawn-queue.service.js.map +1 -0
- package/dist/services/worker-manager/worker-manager.service.d.ts +18 -3
- package/dist/services/worker-manager/worker-manager.service.d.ts.map +1 -1
- package/dist/services/worker-manager/worker-manager.service.js +46 -21
- package/dist/services/worker-manager/worker-manager.service.js.map +1 -1
- package/dist/utils/async.utils.d.ts +51 -0
- package/dist/utils/async.utils.d.ts.map +1 -0
- package/dist/utils/async.utils.js +87 -0
- package/dist/utils/async.utils.js.map +1 -0
- package/dist/utils/helpers.d.ts +4 -123
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +18 -226
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/job.utils.d.ts +50 -0
- package/dist/utils/job.utils.d.ts.map +1 -0
- package/dist/utils/job.utils.js +89 -0
- package/dist/utils/job.utils.js.map +1 -0
- package/dist/utils/naming.utils.d.ts +21 -0
- package/dist/utils/naming.utils.d.ts.map +1 -0
- package/dist/utils/naming.utils.js +38 -0
- package/dist/utils/naming.utils.js.map +1 -0
- package/dist/utils/rate-limit.utils.d.ts +9 -0
- package/dist/utils/rate-limit.utils.d.ts.map +1 -0
- package/dist/utils/rate-limit.utils.js +30 -0
- package/dist/utils/rate-limit.utils.js.map +1 -0
- package/dist/utils/redis.utils.d.ts +3 -0
- package/dist/utils/redis.utils.d.ts.map +1 -0
- package/dist/utils/redis.utils.js +14 -0
- package/dist/utils/redis.utils.js.map +1 -0
- package/package.json +17 -17
- package/dist/decorators/decorators.d.ts +0 -489
- package/dist/decorators/decorators.d.ts.map +0 -1
- package/dist/decorators/decorators.js +0 -680
- package/dist/decorators/decorators.js.map +0 -1
- package/dist/domain/interfaces.d.ts +0 -748
- package/dist/domain/interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces.js +0 -19
- package/dist/domain/interfaces.js.map +0 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { Job } from 'bullmq';
|
|
3
|
+
import { QueueManagerService } from '../queue-manager/queue-manager.service';
|
|
4
|
+
import { QueueEventsManagerService } from '../queue-events-manager/queue-events-manager.service';
|
|
5
|
+
import { WorkerProcessorOptions } from '../../decorators';
|
|
6
|
+
import { IEntityConfig } from '../../domain/interfaces';
|
|
7
|
+
import { EnqueueOptions } from './queue-bus.types';
|
|
8
|
+
/**
|
|
9
|
+
* QueueTarget - Fluent builder for targeting a specific processor's queue
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* await queueBus
|
|
13
|
+
* .forProcessor(TableWorkerProcessor)
|
|
14
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
15
|
+
*/
|
|
16
|
+
export declare class QueueTarget {
|
|
17
|
+
private readonly queueManager;
|
|
18
|
+
private readonly processorClass;
|
|
19
|
+
private readonly processorOptions;
|
|
20
|
+
private readonly entityConfig?;
|
|
21
|
+
private readonly queueEventsManager?;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
constructor(queueManager: QueueManagerService, processorClass: Type<any>, processorOptions: WorkerProcessorOptions, entityConfig?: IEntityConfig | undefined, queueEventsManager?: QueueEventsManagerService | undefined);
|
|
24
|
+
/**
|
|
25
|
+
* Get the queue name function from the processor
|
|
26
|
+
*/
|
|
27
|
+
private getQueueNameFn;
|
|
28
|
+
/**
|
|
29
|
+
* Extract entity ID using the priority chain
|
|
30
|
+
*/
|
|
31
|
+
private extractEntityId;
|
|
32
|
+
/**
|
|
33
|
+
* Enqueue a command/query for processing
|
|
34
|
+
*
|
|
35
|
+
* @param commandOrQuery - The command or query instance
|
|
36
|
+
* @param options - Optional settings (entityId override, jobOptions)
|
|
37
|
+
* @returns The created BullMQ job
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* await queueBus
|
|
41
|
+
* .forProcessor(TableWorkerProcessor)
|
|
42
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
43
|
+
*
|
|
44
|
+
* // With job options
|
|
45
|
+
* await queueBus
|
|
46
|
+
* .forProcessor(TableWorkerProcessor)
|
|
47
|
+
* .enqueue(new DealCommand(tableId), { jobOptions: { delay: 5000 } });
|
|
48
|
+
*/
|
|
49
|
+
enqueue<T extends object>(commandOrQuery: T, options?: EnqueueOptions): Promise<Job>;
|
|
50
|
+
/**
|
|
51
|
+
* Enqueue and wait for result
|
|
52
|
+
*/
|
|
53
|
+
enqueueAndWait<T extends object, R = any>(commandOrQuery: T, options?: EnqueueOptions & {
|
|
54
|
+
timeout?: number;
|
|
55
|
+
}): Promise<R>;
|
|
56
|
+
/**
|
|
57
|
+
* Enqueue multiple commands/queries in bulk
|
|
58
|
+
*/
|
|
59
|
+
enqueueBulk<T extends object>(commandsOrQueries: T[], options?: EnqueueOptions): Promise<Job[]>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=queue-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-target.d.ts","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-target.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,M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AAM,EAChC,iBAAiB,EAAE,CAAC,EAAE,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,EAAE,CAAC;CA6BlB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueueTarget = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const queue_bus_utils_1 = require("./queue-bus.utils");
|
|
6
|
+
/**
|
|
7
|
+
* QueueTarget - Fluent builder for targeting a specific processor's queue
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* await queueBus
|
|
11
|
+
* .forProcessor(TableWorkerProcessor)
|
|
12
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
13
|
+
*/
|
|
14
|
+
class QueueTarget {
|
|
15
|
+
constructor(queueManager, processorClass, processorOptions, entityConfig, queueEventsManager) {
|
|
16
|
+
this.queueManager = queueManager;
|
|
17
|
+
this.processorClass = processorClass;
|
|
18
|
+
this.processorOptions = processorOptions;
|
|
19
|
+
this.entityConfig = entityConfig;
|
|
20
|
+
this.queueEventsManager = queueEventsManager;
|
|
21
|
+
this.logger = new common_1.Logger(QueueTarget.name);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the queue name function from the processor
|
|
25
|
+
*/
|
|
26
|
+
getQueueNameFn() {
|
|
27
|
+
const { queueName } = this.processorOptions;
|
|
28
|
+
if (typeof queueName === 'function') {
|
|
29
|
+
return queueName;
|
|
30
|
+
}
|
|
31
|
+
if (typeof queueName === 'string') {
|
|
32
|
+
// Static queue name or pattern with {entityId}
|
|
33
|
+
return (entityId) => queueName.replace('{entityId}', entityId);
|
|
34
|
+
}
|
|
35
|
+
// Check entity config for custom queue name function
|
|
36
|
+
if (this.entityConfig?.queueName) {
|
|
37
|
+
return this.entityConfig.queueName;
|
|
38
|
+
}
|
|
39
|
+
// Default: entityType-{entityId}-queue
|
|
40
|
+
const { entityType } = this.processorOptions;
|
|
41
|
+
return (entityId) => `${entityType}-${entityId}-queue`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract entity ID using the priority chain
|
|
45
|
+
*/
|
|
46
|
+
extractEntityId(commandOrQuery, data) {
|
|
47
|
+
return (0, queue_bus_utils_1.extractEntityIdExplicit)(commandOrQuery, data, this.processorOptions.defaultEntityId, this.entityConfig, this.logger);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Enqueue a command/query for processing
|
|
51
|
+
*
|
|
52
|
+
* @param commandOrQuery - The command or query instance
|
|
53
|
+
* @param options - Optional settings (entityId override, jobOptions)
|
|
54
|
+
* @returns The created BullMQ job
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* await queueBus
|
|
58
|
+
* .forProcessor(TableWorkerProcessor)
|
|
59
|
+
* .enqueue(new MakeBetCommand(tableId, bets, player));
|
|
60
|
+
*
|
|
61
|
+
* // With job options
|
|
62
|
+
* await queueBus
|
|
63
|
+
* .forProcessor(TableWorkerProcessor)
|
|
64
|
+
* .enqueue(new DealCommand(tableId), { jobOptions: { delay: 5000 } });
|
|
65
|
+
*/
|
|
66
|
+
async enqueue(commandOrQuery, options) {
|
|
67
|
+
const jobName = (0, queue_bus_utils_1.getJobName)(commandOrQuery);
|
|
68
|
+
const data = (0, queue_bus_utils_1.extractData)(commandOrQuery);
|
|
69
|
+
const entityId = options?.entityId ?? this.extractEntityId(commandOrQuery, data);
|
|
70
|
+
// Get queue name from processor's queueName function
|
|
71
|
+
const queueNameFn = this.getQueueNameFn();
|
|
72
|
+
const queueName = queueNameFn(entityId);
|
|
73
|
+
// Add job via QueueManager (which handles event listening setup)
|
|
74
|
+
const { entityType } = this.processorOptions;
|
|
75
|
+
this.logger.debug(`[${this.processorClass.name}] Adding job ${jobName} to queue ${queueName}`);
|
|
76
|
+
// Get queue and ensure event listening
|
|
77
|
+
const queue = this.queueManager.getOrCreateQueue(queueName);
|
|
78
|
+
if (this.queueEventsManager) {
|
|
79
|
+
await this.queueEventsManager.ensureListening(queueName, entityType);
|
|
80
|
+
}
|
|
81
|
+
// Add job to queue
|
|
82
|
+
return queue.add(jobName, data, options?.jobOptions);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Enqueue and wait for result
|
|
86
|
+
*/
|
|
87
|
+
async enqueueAndWait(commandOrQuery, options) {
|
|
88
|
+
const job = await this.enqueue(commandOrQuery, options);
|
|
89
|
+
const data = (0, queue_bus_utils_1.extractData)(commandOrQuery);
|
|
90
|
+
const entityId = options?.entityId ?? this.extractEntityId(commandOrQuery, data);
|
|
91
|
+
const queueNameFn = this.getQueueNameFn();
|
|
92
|
+
const queueName = queueNameFn(entityId);
|
|
93
|
+
const queueEvents = await this.queueManager.getQueueEvents(queueName);
|
|
94
|
+
return job.waitUntilFinished(queueEvents, options?.timeout);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enqueue multiple commands/queries in bulk
|
|
98
|
+
*/
|
|
99
|
+
async enqueueBulk(commandsOrQueries, options) {
|
|
100
|
+
if (commandsOrQueries.length === 0)
|
|
101
|
+
return [];
|
|
102
|
+
const firstCmd = commandsOrQueries[0];
|
|
103
|
+
const firstData = (0, queue_bus_utils_1.extractData)(firstCmd);
|
|
104
|
+
const entityId = options?.entityId ?? this.extractEntityId(firstCmd, firstData);
|
|
105
|
+
const queueNameFn = this.getQueueNameFn();
|
|
106
|
+
const queueName = queueNameFn(entityId);
|
|
107
|
+
const queue = this.queueManager.getOrCreateQueue(queueName);
|
|
108
|
+
// Ensure listening is set up for auto-spawn
|
|
109
|
+
const { entityType } = this.processorOptions;
|
|
110
|
+
if (this.queueEventsManager) {
|
|
111
|
+
await this.queueEventsManager.ensureListening(queueName, entityType);
|
|
112
|
+
}
|
|
113
|
+
const bulkJobs = commandsOrQueries.map((cmd) => ({
|
|
114
|
+
name: (0, queue_bus_utils_1.getJobName)(cmd),
|
|
115
|
+
data: (0, queue_bus_utils_1.extractData)(cmd),
|
|
116
|
+
opts: options?.jobOptions,
|
|
117
|
+
}));
|
|
118
|
+
this.logger.debug(`[${this.processorClass.name}] Adding ${bulkJobs.length} jobs to queue ${queueName}`);
|
|
119
|
+
return queue.addBulk(bulkJobs);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.QueueTarget = QueueTarget;
|
|
123
|
+
//# sourceMappingURL=queue-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-target.js","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-target.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAO9C,uDAAqF;AAErF;;;;;;;GAOG;AACH,MAAa,WAAW;IAGtB,YACmB,YAAiC,EACjC,cAAyB,EACzB,gBAAwC,EACxC,YAA4B,EAC5B,kBAA8C;QAJ9C,iBAAY,GAAZ,YAAY,CAAqB;QACjC,mBAAc,GAAd,cAAc,CAAW;QACzB,qBAAgB,GAAhB,gBAAgB,CAAwB;QACxC,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,uBAAkB,GAAlB,kBAAkB,CAA4B;QAPhD,WAAM,GAAG,IAAI,eAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAQpD,CAAC;IAEJ;;OAEG;IACK,cAAc;QACpB,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAE5C,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;YACpC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClC,+CAA+C;YAC/C,OAAO,CAAC,QAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACzE,CAAC;QAED,qDAAqD;QACrD,IAAI,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC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AAC,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAE5D,4CAA4C;QAC5C,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC7C,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,IAAA,4BAAU,EAAC,GAAG,CAAC;YACrB,IAAI,EAAE,IAAA,6BAAW,EAAC,GAAG,CAAC;YACtB,IAAI,EAAE,OAAO,EAAE,UAAU;SAC1B,CAAC,CAAC,CAAC;QAEJ,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,YAAY,QAAQ,CAAC,MAAM,kBAAkB,SAAS,EAAE,CACrF,CAAC;QAEF,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AArJD,kCAqJC"}
|
|
@@ -3,6 +3,7 @@ import Redis from 'ioredis';
|
|
|
3
3
|
import { IAtomicQueuesModuleConfig } from '../../domain';
|
|
4
4
|
import { WorkerManagerService } from '../worker-manager';
|
|
5
5
|
import { ServiceQueueManager } from '../service-queue';
|
|
6
|
+
import { SpawnQueueService } from '../spawn-queue';
|
|
6
7
|
/**
|
|
7
8
|
* Callback for spawning a worker for an entity.
|
|
8
9
|
*/
|
|
@@ -41,6 +42,7 @@ export declare class QueueEventsManagerService implements OnModuleDestroy {
|
|
|
41
42
|
private readonly redis;
|
|
42
43
|
private readonly config;
|
|
43
44
|
private readonly workerManager;
|
|
45
|
+
private readonly spawnQueueService?;
|
|
44
46
|
private readonly serviceQueueManager?;
|
|
45
47
|
private readonly logger;
|
|
46
48
|
private readonly registeredQueues;
|
|
@@ -48,7 +50,8 @@ export declare class QueueEventsManagerService implements OnModuleDestroy {
|
|
|
48
50
|
private readonly useServiceQueue;
|
|
49
51
|
private readonly entityPatterns;
|
|
50
52
|
private onJobArrivedCallback;
|
|
51
|
-
|
|
53
|
+
private readonly hotCache;
|
|
54
|
+
constructor(redis: Redis, config: IAtomicQueuesModuleConfig, workerManager: WorkerManagerService, spawnQueueService?: SpawnQueueService | undefined, serviceQueueManager?: ServiceQueueManager | undefined);
|
|
52
55
|
/**
|
|
53
56
|
* Register a callback to be called when a job arrives for any queue
|
|
54
57
|
* and no worker exists. Used by ProcessorDiscoveryService.
|
|
@@ -69,9 +72,27 @@ export declare class QueueEventsManagerService implements OnModuleDestroy {
|
|
|
69
72
|
*/
|
|
70
73
|
listenToQueue(queueName: string, entityType: string, extractEntityId: (queueName: string) => string): Promise<void>;
|
|
71
74
|
/**
|
|
72
|
-
* Handle job arrival -
|
|
75
|
+
* Handle job arrival — ultra-low-latency path.
|
|
76
|
+
*
|
|
77
|
+
* Hot path (worker exists in cache): 0 Redis calls. Instant return.
|
|
78
|
+
* Warm path (worker exists in Redis): 1 Redis EXISTS call (O(1)).
|
|
79
|
+
* Cold path (no worker): 1 SET NX claim + direct local creation.
|
|
80
|
+
*
|
|
81
|
+
* This replaces the old flow of: KEYS scan → spawn queue enqueue →
|
|
82
|
+
* spawn queue dequeue → create worker (multiple seconds) with:
|
|
83
|
+
* cache hit → 0ms, or SET NX + local create → ~10ms.
|
|
73
84
|
*/
|
|
74
85
|
private handleJobArrived;
|
|
86
|
+
/**
|
|
87
|
+
* Evict a worker from the hot cache.
|
|
88
|
+
* Called by SpawnQueueService when idle sweep closes a worker,
|
|
89
|
+
* so the next job arrival will trigger a fresh spawn.
|
|
90
|
+
*/
|
|
91
|
+
evictFromHotCache(workerName: string): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get the hot cache size (for diagnostics).
|
|
94
|
+
*/
|
|
95
|
+
getHotCacheSize(): number;
|
|
75
96
|
/**
|
|
76
97
|
* Listen to all queues that match a pattern.
|
|
77
98
|
* Uses Redis SCAN to find existing queues and listens to them.
|
|
@@ -91,10 +112,6 @@ export declare class QueueEventsManagerService implements OnModuleDestroy {
|
|
|
91
112
|
* Get all registered queue names.
|
|
92
113
|
*/
|
|
93
114
|
getRegisteredQueues(): string[];
|
|
94
|
-
/**
|
|
95
|
-
* Scan Redis keys matching a pattern.
|
|
96
|
-
*/
|
|
97
|
-
private scanKeys;
|
|
98
115
|
/**
|
|
99
116
|
* Cleanup on module destroy.
|
|
100
117
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-events-manager.service.d.ts","sourceRoot":"","sources":["../../../src/services/queue-events-manager/queue-events-manager.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"queue-events-manager.service.d.ts","sourceRoot":"","sources":["../../../src/services/queue-events-manager/queue-events-manager.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAwB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,IAAI,CAAC,CAAC;AAYnB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UAAU,EAAE,MAAM,GAAG,IAAI;IAI3C;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACG,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0CjE;;;OAGG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB3E;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrD;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE;IAI/B;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAoBvC"}
|
|
@@ -21,8 +21,10 @@ const common_1 = require("@nestjs/common");
|
|
|
21
21
|
const bullmq_1 = require("bullmq");
|
|
22
22
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
23
23
|
const constants_1 = require("../constants");
|
|
24
|
+
const utils_1 = require("../../utils");
|
|
24
25
|
const worker_manager_1 = require("../worker-manager");
|
|
25
26
|
const service_queue_1 = require("../service-queue");
|
|
27
|
+
const spawn_queue_1 = require("../spawn-queue");
|
|
26
28
|
/**
|
|
27
29
|
* QueueEventsManagerService
|
|
28
30
|
*
|
|
@@ -54,10 +56,11 @@ const service_queue_1 = require("../service-queue");
|
|
|
54
56
|
* ```
|
|
55
57
|
*/
|
|
56
58
|
let QueueEventsManagerService = QueueEventsManagerService_1 = class QueueEventsManagerService {
|
|
57
|
-
constructor(redis, config, workerManager, serviceQueueManager) {
|
|
59
|
+
constructor(redis, config, workerManager, spawnQueueService, serviceQueueManager) {
|
|
58
60
|
this.redis = redis;
|
|
59
61
|
this.config = config;
|
|
60
62
|
this.workerManager = workerManager;
|
|
63
|
+
this.spawnQueueService = spawnQueueService;
|
|
61
64
|
this.serviceQueueManager = serviceQueueManager;
|
|
62
65
|
this.logger = new common_1.Logger(QueueEventsManagerService_1.name);
|
|
63
66
|
this.registeredQueues = new Map();
|
|
@@ -65,7 +68,14 @@ let QueueEventsManagerService = QueueEventsManagerService_1 = class QueueEventsM
|
|
|
65
68
|
this.entityPatterns = new Map();
|
|
66
69
|
// Global callback for spawning workers
|
|
67
70
|
this.onJobArrivedCallback = null;
|
|
68
|
-
|
|
71
|
+
// =========================================================================
|
|
72
|
+
// HOT CACHE — eliminates Redis calls on the warm path entirely.
|
|
73
|
+
// Once we know a worker exists (via Redis check or local creation),
|
|
74
|
+
// we cache the worker name. Subsequent job arrivals for that entity
|
|
75
|
+
// short-circuit without touching Redis at all.
|
|
76
|
+
// =========================================================================
|
|
77
|
+
this.hotCache = new Set();
|
|
78
|
+
this.keyPrefix = (0, utils_1.resolveKeyPrefix)(config);
|
|
69
79
|
this.useServiceQueue = config.serviceQueue?.enabled !== false;
|
|
70
80
|
}
|
|
71
81
|
/**
|
|
@@ -146,45 +156,78 @@ let QueueEventsManagerService = QueueEventsManagerService_1 = class QueueEventsM
|
|
|
146
156
|
this.logger.log(`Listening to queue events: ${queueName}`);
|
|
147
157
|
}
|
|
148
158
|
/**
|
|
149
|
-
* Handle job arrival -
|
|
159
|
+
* Handle job arrival — ultra-low-latency path.
|
|
160
|
+
*
|
|
161
|
+
* Hot path (worker exists in cache): 0 Redis calls. Instant return.
|
|
162
|
+
* Warm path (worker exists in Redis): 1 Redis EXISTS call (O(1)).
|
|
163
|
+
* Cold path (no worker): 1 SET NX claim + direct local creation.
|
|
164
|
+
*
|
|
165
|
+
* This replaces the old flow of: KEYS scan → spawn queue enqueue →
|
|
166
|
+
* spawn queue dequeue → create worker (multiple seconds) with:
|
|
167
|
+
* cache hit → 0ms, or SET NX + local create → ~10ms.
|
|
150
168
|
*/
|
|
151
169
|
async handleJobArrived(queueName, entityType, extractEntityId, jobId) {
|
|
152
170
|
const entityId = extractEntityId(queueName);
|
|
153
|
-
this.logger.debug(`[QueueEvents] Job ${jobId} waiting in ${queueName} (entity: ${entityType}/${entityId})`);
|
|
154
171
|
// Check if worker already exists for this entity
|
|
155
172
|
const pattern = this.entityPatterns.get(entityType);
|
|
156
|
-
if (!pattern)
|
|
157
|
-
this.logger.warn(`No pattern registered for entity type: ${entityType}`);
|
|
173
|
+
if (!pattern)
|
|
158
174
|
return;
|
|
159
|
-
}
|
|
160
175
|
const workerName = pattern.workerNameFn(entityId);
|
|
176
|
+
// ── HOT CACHE (0 Redis calls) ────────────────────────────────
|
|
177
|
+
if (this.hotCache.has(workerName))
|
|
178
|
+
return;
|
|
179
|
+
// ── WARM PATH (1 Redis EXISTS — O(1)) ────────────────────────
|
|
161
180
|
const workerExists = await this.workerManager.workerExists(workerName);
|
|
162
181
|
if (workerExists) {
|
|
163
|
-
this.
|
|
182
|
+
this.hotCache.add(workerName);
|
|
164
183
|
return;
|
|
165
184
|
}
|
|
166
|
-
|
|
167
|
-
//
|
|
168
|
-
|
|
185
|
+
// ── COLD PATH — Direct local spawn ───────────────────────────
|
|
186
|
+
// Atomic claim via SET NX: if this pod wins, it creates the
|
|
187
|
+
// worker locally (no spawn queue round-trip). If another pod
|
|
188
|
+
// already claimed it, we skip (that pod is creating it).
|
|
189
|
+
const claimed = await this.workerManager.claimWorkerSlot(workerName);
|
|
190
|
+
if (claimed) {
|
|
191
|
+
this.logger.log(`[QueueEvents] Claimed ${entityType}/${entityId} — creating worker locally`);
|
|
192
|
+
// Direct local spawn (same-pod, no BullMQ round-trip)
|
|
169
193
|
try {
|
|
170
|
-
|
|
171
|
-
|
|
194
|
+
if (this.onJobArrivedCallback) {
|
|
195
|
+
await this.onJobArrivedCallback(entityType, entityId, queueName);
|
|
196
|
+
}
|
|
197
|
+
else if (this.spawnQueueService) {
|
|
198
|
+
// If only spawn handler is registered, invoke it directly
|
|
199
|
+
await this.spawnQueueService.handleSpawnJobDirect?.(entityType, entityId);
|
|
200
|
+
}
|
|
201
|
+
this.hotCache.add(workerName);
|
|
172
202
|
}
|
|
173
203
|
catch (error) {
|
|
174
|
-
this.logger.error(`[QueueEvents]
|
|
204
|
+
this.logger.error(`[QueueEvents] Direct spawn failed for ${entityType}/${entityId}: ${error.message}`);
|
|
205
|
+
// Fall back to spawn queue if direct creation failed
|
|
206
|
+
if (this.spawnQueueService) {
|
|
207
|
+
await this.spawnQueueService.requestSpawn(entityType, entityId);
|
|
208
|
+
}
|
|
175
209
|
}
|
|
176
210
|
}
|
|
177
|
-
else
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this.logger.debug(`[QueueEvents] Worker spawned directly for ${entityType}/${entityId}`);
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
this.logger.error(`[QueueEvents] Failed to spawn worker: ${error.message}`);
|
|
185
|
-
}
|
|
211
|
+
else {
|
|
212
|
+
// Another pod claimed it — it'll be created there.
|
|
213
|
+
// Add to cache after a short delay (the other pod needs time to create).
|
|
214
|
+
setTimeout(() => this.hotCache.add(workerName), 500);
|
|
186
215
|
}
|
|
187
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Evict a worker from the hot cache.
|
|
219
|
+
* Called by SpawnQueueService when idle sweep closes a worker,
|
|
220
|
+
* so the next job arrival will trigger a fresh spawn.
|
|
221
|
+
*/
|
|
222
|
+
evictFromHotCache(workerName) {
|
|
223
|
+
this.hotCache.delete(workerName);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get the hot cache size (for diagnostics).
|
|
227
|
+
*/
|
|
228
|
+
getHotCacheSize() {
|
|
229
|
+
return this.hotCache.size;
|
|
230
|
+
}
|
|
188
231
|
/**
|
|
189
232
|
* Listen to all queues that match a pattern.
|
|
190
233
|
* Uses Redis SCAN to find existing queues and listens to them.
|
|
@@ -200,7 +243,7 @@ let QueueEventsManagerService = QueueEventsManagerService_1 = class QueueEventsM
|
|
|
200
243
|
const queuePattern = `${this.keyPrefix}:${entityType}:*:queue`;
|
|
201
244
|
const bulkQueuePattern = `bull:${this.keyPrefix}:${entityType}:*:queue:*`;
|
|
202
245
|
// Scan for existing BullMQ queue keys
|
|
203
|
-
const keys = await
|
|
246
|
+
const keys = await (0, utils_1.scanKeys)(this.redis, bulkQueuePattern);
|
|
204
247
|
const queueNames = new Set();
|
|
205
248
|
for (const key of keys) {
|
|
206
249
|
// Extract queue name from BullMQ key
|
|
@@ -268,19 +311,6 @@ let QueueEventsManagerService = QueueEventsManagerService_1 = class QueueEventsM
|
|
|
268
311
|
getRegisteredQueues() {
|
|
269
312
|
return Array.from(this.registeredQueues.keys());
|
|
270
313
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Scan Redis keys matching a pattern.
|
|
273
|
-
*/
|
|
274
|
-
async scanKeys(pattern) {
|
|
275
|
-
let cursor = '0';
|
|
276
|
-
const keys = [];
|
|
277
|
-
do {
|
|
278
|
-
const [nextCursor, scanKeys] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
279
|
-
cursor = nextCursor;
|
|
280
|
-
keys.push(...scanKeys);
|
|
281
|
-
} while (cursor !== '0');
|
|
282
|
-
return keys;
|
|
283
|
-
}
|
|
284
314
|
/**
|
|
285
315
|
* Cleanup on module destroy.
|
|
286
316
|
*/
|
|
@@ -305,7 +335,9 @@ exports.QueueEventsManagerService = QueueEventsManagerService = QueueEventsManag
|
|
|
305
335
|
__param(0, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_REDIS)),
|
|
306
336
|
__param(1, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_CONFIG)),
|
|
307
337
|
__param(3, (0, common_1.Optional)()),
|
|
338
|
+
__param(4, (0, common_1.Optional)()),
|
|
308
339
|
__metadata("design:paramtypes", [ioredis_1.default, Object, worker_manager_1.WorkerManagerService,
|
|
340
|
+
spawn_queue_1.SpawnQueueService,
|
|
309
341
|
service_queue_1.ServiceQueueManager])
|
|
310
342
|
], QueueEventsManagerService);
|
|
311
343
|
//# sourceMappingURL=queue-events-manager.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue-events-manager.service.js","sourceRoot":"","sources":["../../../src/services/queue-events-manager/queue-events-manager.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,mCAAqC;AACrC,sDAA4B;AAC5B,4CAAyE;AAEzE,sDAAyD;AACzD,oDAA6E;
|
|
1
|
+
{"version":3,"file":"queue-events-manager.service.js","sourceRoot":"","sources":["../../../src/services/queue-events-manager/queue-events-manager.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,mCAAqC;AACrC,sDAA4B;AAC5B,4CAAyE;AAEzE,uCAAyD;AACzD,sDAAyD;AACzD,oDAA6E;AAC7E,gDAAmD;AAqBnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEI,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAwBpC,YAC+B,KAA6B,EAE1D,MAAkD,EACjC,aAAmC,EACxC,iBAAsD,EACtD,mBAA0D;QALxB,UAAK,GAAL,KAAK,CAAO;QAEzC,WAAM,GAAN,MAAM,CAA2B;QACjC,kBAAa,GAAb,aAAa,CAAsB;QACvB,sBAAiB,GAAjB,iBAAiB,CAAoB;QACrC,wBAAmB,GAAnB,mBAAmB,CAAsB;QA7BvD,WAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;QACpD,qBAAgB,GAAuC,IAAI,GAAG,EAAE,CAAC;QAIlF,qDAAqD;QACpC,mBAAc,GAI1B,IAAI,GAAG,EAAE,CAAC;QAEf,uCAAuC;QAC/B,yBAAoB,GAAgC,IAAI,CAAC;QAEjE,4EAA4E;QAC5E,gEAAgE;QAChE,oEAAoE;QACpE,oEAAoE;QACpE,+CAA+C;QAC/C,4EAA4E;QAC3D,aAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;QAUjD,IAAI,CAAC,SAAS,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,YAA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AAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAE1D,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAClE,KAAK,EAAE,UAAU,EAAE,EAAE;YACnB,IAAI,CAAC;gBACH,MAAM,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;YACvC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,kCAAkC,UAAU,CAAC,SAAS,GAAG,EACzD,KAAK,CACN,CAAC;YACJ,CAAC;QACH,CAAC,CACF,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AA1VY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IA0BR,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,eAAM,EAAC,gCAAoB,CAAC,CAAA;IAG5B,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,iBAAQ,GAAE,CAAA;qCAL0C,iBAAK,UAG1B,qCAAoB;QACH,+BAAiB;QACf,mCAAmB;GA9B7D,yBAAyB,CA0VrC"}
|
|
@@ -112,10 +112,6 @@ export declare class ResourceLockService implements IResourceLockService {
|
|
|
112
112
|
* Get the Redis key for a lock.
|
|
113
113
|
*/
|
|
114
114
|
private getLockKey;
|
|
115
|
-
/**
|
|
116
|
-
* Scan Redis keys matching a pattern.
|
|
117
|
-
*/
|
|
118
|
-
private scanKeys;
|
|
119
115
|
/**
|
|
120
116
|
* Fisher-Yates shuffle algorithm.
|
|
121
117
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-lock.service.d.ts","sourceRoot":"","sources":["../../../src/services/resource-lock/resource-lock.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,yBAAyB,EAC1B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-lock.service.d.ts","sourceRoot":"","sources":["../../../src/services/resource-lock/resource-lock.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBACa,mBAAoB,YAAW,oBAAoB;IAwD/B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAEnD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAzDzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAGnC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAalC;IAGF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAiBlC;IAGF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAYjC;gBAG8C,KAAK,EAAE,KAAK,EAEzC,MAAM,EAAE,yBAAyB;IAKpD;;;;;OAKG;IACG,WAAW,CACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,UAAU,SAAK,EACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,WAAW,CAAC;I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AAG,OAAO,CAAC,MAAM,CAAC;IAsB1E;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,OAAO,CAAC,YAAY;CAOrB"}
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.ResourceLockService = void 0;
|
|
20
20
|
const common_1 = require("@nestjs/common");
|
|
21
21
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
22
|
+
const utils_1 = require("../../utils");
|
|
22
23
|
const constants_1 = require("../constants");
|
|
23
24
|
/**
|
|
24
25
|
* ResourceLockService
|
|
@@ -116,7 +117,7 @@ let ResourceLockService = ResourceLockService_1 = class ResourceLockService {
|
|
|
116
117
|
return 0 -- Lock doesn't exist
|
|
117
118
|
end
|
|
118
119
|
`;
|
|
119
|
-
this.keyPrefix = config
|
|
120
|
+
this.keyPrefix = (0, utils_1.resolveKeyPrefix)(config);
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* Acquire a lock on a resource.
|
|
@@ -227,7 +228,7 @@ let ResourceLockService = ResourceLockService_1 = class ResourceLockService {
|
|
|
227
228
|
async getOwnerLocks(ownerType, ownerId) {
|
|
228
229
|
// Scan for all locks and filter by owner
|
|
229
230
|
const pattern = `${this.keyPrefix}:lock:*`;
|
|
230
|
-
const keys = await
|
|
231
|
+
const keys = await (0, utils_1.scanKeys)(this.redis, pattern);
|
|
231
232
|
const locks = [];
|
|
232
233
|
for (const key of keys) {
|
|
233
234
|
const data = await this.redis.get(key);
|
|
@@ -293,7 +294,7 @@ let ResourceLockService = ResourceLockService_1 = class ResourceLockService {
|
|
|
293
294
|
*/
|
|
294
295
|
async getResourceTypeLocks(resourceType) {
|
|
295
296
|
const pattern = `${this.keyPrefix}:lock:${resourceType}:*`;
|
|
296
|
-
const keys = await
|
|
297
|
+
const keys = await (0, utils_1.scanKeys)(this.redis, pattern);
|
|
297
298
|
const locked = [];
|
|
298
299
|
for (const key of keys) {
|
|
299
300
|
const data = await this.redis.get(key);
|
|
@@ -345,19 +346,6 @@ let ResourceLockService = ResourceLockService_1 = class ResourceLockService {
|
|
|
345
346
|
getLockKey(resourceType, resourceId) {
|
|
346
347
|
return `${this.keyPrefix}:lock:${resourceType}:${resourceId}`;
|
|
347
348
|
}
|
|
348
|
-
/**
|
|
349
|
-
* Scan Redis keys matching a pattern.
|
|
350
|
-
*/
|
|
351
|
-
async scanKeys(pattern) {
|
|
352
|
-
let cursor = '0';
|
|
353
|
-
const keys = [];
|
|
354
|
-
do {
|
|
355
|
-
const [nextCursor, scanKeys] = await this.redis.scan(cursor, 'MATCH', pattern, 'COUNT', 100);
|
|
356
|
-
cursor = nextCursor;
|
|
357
|
-
keys.push(...scanKeys);
|
|
358
|
-
} while (cursor !== '0');
|
|
359
|
-
return keys;
|
|
360
|
-
}
|
|
361
349
|
/**
|
|
362
350
|
* Fisher-Yates shuffle algorithm.
|
|
363
351
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-lock.service.js","sourceRoot":"","sources":["../../../src/services/resource-lock/resource-lock.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,sDAA4B;AAO5B,4CAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEI,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAuD9B,YAC+B,KAA6B,EAE1D,MAAkD;QAFJ,UAAK,GAAL,KAAK,CAAO;QAEzC,WAAM,GAAN,MAAM,CAA2B;QAzDnC,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAG/D,yCAAyC;QACxB,wBAAmB,GAAG;;;;;;;;;;;;;GAatC,CAAC;QAEF,0DAA0D;QACzC,wBAAmB,GAAG;;;;;;;;;;;;;;;;;GAiBtC,CAAC;QAEF,oCAAoC;QACnB,uBAAkB,GAAG;;;;;;;;;;;;GAYrC,CAAC;QAOA,IAAI,CAAC,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"resource-lock.service.js","sourceRoot":"","sources":["../../../src/services/resource-lock/resource-lock.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,sDAA4B;AAO5B,uCAAyD;AACzD,4CAAyE;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEI,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAuD9B,YAC+B,KAA6B,EAE1D,MAAkD;QAFJ,UAAK,GAAL,KAAK,CAAO;QAEzC,WAAM,GAAN,MAAM,CAA2B;QAzDnC,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAG/D,yCAAyC;QACxB,wBAAmB,GAAG;;;;;;;;;;;;;GAatC,CAAC;QAEF,0DAA0D;QACzC,wBAAmB,GAAG;;;;;;;;;;;;;;;;;GAiBtC,CAAC;QAEF,oCAAoC;QACnB,uBAAkB,GAAG;;;;;;;;;;;;GAYrC,CAAC;QAOA,IAAI,CAAC,SAAS,GAAG,IAAA,wBAAgB,EAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CACf,YAAoB,EACpB,UAAkB,EAClB,OAAe,EACf,SAAiB,EACjB,UAAU,GAAG,EAAE,EACf,QAAkC;QAElC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAEvB,MAAM,QAAQ,GAAkB;YAC9B,UAAU;YACV,YAAY;YACZ,OAAO;YACP,SAAS;YACT,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC;YACtD,QAAQ;SACT,CAAC;QAEF,IA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AAC;IAChE,CAAC;IAED;;OAEG;IACK,YAAY,CAAI,KAAU;QAChC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AA7ZY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAyDR,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,eAAM,EAAC,gCAAoB,CAAC,CAAA;qCADwB,iBAAK;GAxDjD,mBAAmB,CA6Z/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/service-queue/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/service-queue/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./service-queue.service"), exports);
|
|
18
|
+
__exportStar(require("./service-queue.types"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|