atomic-queues 1.0.13
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 +686 -0
- package/dist/decorators/decorators.d.ts +67 -0
- package/dist/decorators/decorators.d.ts.map +1 -0
- package/dist/decorators/decorators.js +91 -0
- package/dist/decorators/decorators.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +18 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/domain/index.d.ts +5 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +21 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/interfaces.d.ts +614 -0
- package/dist/domain/interfaces.d.ts.map +1 -0
- package/dist/domain/interfaces.js +19 -0
- package/dist/domain/interfaces.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/module/atomic-queues.module.d.ts +97 -0
- package/dist/module/atomic-queues.module.d.ts.map +1 -0
- package/dist/module/atomic-queues.module.js +197 -0
- package/dist/module/atomic-queues.module.js.map +1 -0
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +18 -0
- package/dist/module/index.js.map +1 -0
- package/dist/services/constants.d.ts +10 -0
- package/dist/services/constants.d.ts.map +1 -0
- package/dist/services/constants.js +13 -0
- package/dist/services/constants.js.map +1 -0
- package/dist/services/cron-manager/cron-manager.service.d.ts +188 -0
- package/dist/services/cron-manager/cron-manager.service.d.ts.map +1 -0
- package/dist/services/cron-manager/cron-manager.service.js +534 -0
- package/dist/services/cron-manager/cron-manager.service.js.map +1 -0
- package/dist/services/cron-manager/index.d.ts +2 -0
- package/dist/services/cron-manager/index.d.ts.map +1 -0
- package/dist/services/cron-manager/index.js +18 -0
- package/dist/services/cron-manager/index.js.map +1 -0
- package/dist/services/index-manager/index-manager.service.d.ts +146 -0
- package/dist/services/index-manager/index-manager.service.d.ts.map +1 -0
- package/dist/services/index-manager/index-manager.service.js +337 -0
- package/dist/services/index-manager/index-manager.service.js.map +1 -0
- package/dist/services/index-manager/index.d.ts +2 -0
- package/dist/services/index-manager/index.d.ts.map +1 -0
- package/dist/services/index-manager/index.js +18 -0
- package/dist/services/index-manager/index.js.map +1 -0
- package/dist/services/index.d.ts +10 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +26 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/job-processor/index.d.ts +2 -0
- package/dist/services/job-processor/index.d.ts.map +1 -0
- package/dist/services/job-processor/index.js +18 -0
- package/dist/services/job-processor/index.js.map +1 -0
- package/dist/services/job-processor/job-processor.service.d.ts +156 -0
- package/dist/services/job-processor/job-processor.service.d.ts.map +1 -0
- package/dist/services/job-processor/job-processor.service.js +331 -0
- package/dist/services/job-processor/job-processor.service.js.map +1 -0
- package/dist/services/queue-manager/index.d.ts +2 -0
- package/dist/services/queue-manager/index.d.ts.map +1 -0
- package/dist/services/queue-manager/index.js +18 -0
- package/dist/services/queue-manager/index.js.map +1 -0
- package/dist/services/queue-manager/queue-manager.service.d.ts +128 -0
- package/dist/services/queue-manager/queue-manager.service.d.ts.map +1 -0
- package/dist/services/queue-manager/queue-manager.service.js +308 -0
- package/dist/services/queue-manager/queue-manager.service.js.map +1 -0
- package/dist/services/resource-lock/index.d.ts +2 -0
- package/dist/services/resource-lock/index.d.ts.map +1 -0
- package/dist/services/resource-lock/index.js +18 -0
- package/dist/services/resource-lock/index.js.map +1 -0
- package/dist/services/resource-lock/resource-lock.service.d.ts +124 -0
- package/dist/services/resource-lock/resource-lock.service.d.ts.map +1 -0
- package/dist/services/resource-lock/resource-lock.service.js +379 -0
- package/dist/services/resource-lock/resource-lock.service.js.map +1 -0
- package/dist/services/service-queue/index.d.ts +2 -0
- package/dist/services/service-queue/index.d.ts.map +1 -0
- package/dist/services/service-queue/index.js +18 -0
- package/dist/services/service-queue/index.js.map +1 -0
- package/dist/services/service-queue/service-queue.service.d.ts +232 -0
- package/dist/services/service-queue/service-queue.service.d.ts.map +1 -0
- package/dist/services/service-queue/service-queue.service.js +647 -0
- package/dist/services/service-queue/service-queue.service.js.map +1 -0
- package/dist/services/shutdown-state/index.d.ts +2 -0
- package/dist/services/shutdown-state/index.d.ts.map +1 -0
- package/dist/services/shutdown-state/index.js +18 -0
- package/dist/services/shutdown-state/index.js.map +1 -0
- package/dist/services/shutdown-state/shutdown-state.service.d.ts +69 -0
- package/dist/services/shutdown-state/shutdown-state.service.d.ts.map +1 -0
- package/dist/services/shutdown-state/shutdown-state.service.js +127 -0
- package/dist/services/shutdown-state/shutdown-state.service.js.map +1 -0
- package/dist/services/worker-manager/index.d.ts +2 -0
- package/dist/services/worker-manager/index.d.ts.map +1 -0
- package/dist/services/worker-manager/index.js +18 -0
- package/dist/services/worker-manager/index.js.map +1 -0
- package/dist/services/worker-manager/worker-manager.service.d.ts +163 -0
- package/dist/services/worker-manager/worker-manager.service.d.ts.map +1 -0
- package/dist/services/worker-manager/worker-manager.service.js +460 -0
- package/dist/services/worker-manager/worker-manager.service.js.map +1 -0
- package/dist/utils/helpers.d.ts +124 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +229 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata keys for decorators
|
|
3
|
+
*/
|
|
4
|
+
export declare const ATOMIC_PROCESSOR_METADATA = "atomic:processor";
|
|
5
|
+
export declare const ENTITY_TYPE_METADATA = "atomic:entity-type";
|
|
6
|
+
export declare const JOB_TYPE_METADATA = "atomic:job-type";
|
|
7
|
+
/**
|
|
8
|
+
* @AtomicProcessor decorator
|
|
9
|
+
*
|
|
10
|
+
* Marks a method as an atomic job processor.
|
|
11
|
+
* Can be used on handler methods to auto-register them.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @Injectable()
|
|
16
|
+
* export class MessageProcessor {
|
|
17
|
+
* @AtomicProcessor('send-message')
|
|
18
|
+
* async handleSendMessage(job: Job<IAtomicJobData>) {
|
|
19
|
+
* // Process the job
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const AtomicProcessor: (jobType: string) => MethodDecorator;
|
|
25
|
+
/**
|
|
26
|
+
* @EntityType decorator
|
|
27
|
+
*
|
|
28
|
+
* Marks a class or method with an entity type for automatic registration.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* @Injectable()
|
|
33
|
+
* @EntityType('user')
|
|
34
|
+
* export class UserWorkerService {
|
|
35
|
+
* // All methods in this service are associated with 'user' entity type
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const EntityType: (entityType: string) => ClassDecorator & MethodDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* @JobType decorator
|
|
42
|
+
*
|
|
43
|
+
* Specifies the job type for a processor method.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* @Injectable()
|
|
48
|
+
* export class TableProcessor {
|
|
49
|
+
* @JobType('make-bet')
|
|
50
|
+
* async handleMakeBet(job: Job) {
|
|
51
|
+
* // Process bet
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const JobType: (jobType: string) => MethodDecorator;
|
|
57
|
+
/**
|
|
58
|
+
* @InjectAtomicQueue decorator
|
|
59
|
+
*
|
|
60
|
+
* Custom parameter decorator for injecting a specific queue.
|
|
61
|
+
* Useful when you need direct access to a queue in a service.
|
|
62
|
+
*
|
|
63
|
+
* Note: This is a placeholder - actual implementation would use
|
|
64
|
+
* NestJS's custom parameter decorators with module injection.
|
|
65
|
+
*/
|
|
66
|
+
export declare const InjectAtomicQueue: (entityType: string, entityId?: string) => ParameterDecorator;
|
|
67
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AACzD,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,eAEjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GAAI,YAAY,MAAM,KAAG,cAAc,GAAG,eAEhE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,KAAG,eAEzC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,MAAM,EAClB,WAAW,MAAM,KAChB,kBAsBF,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InjectAtomicQueue = exports.JobType = exports.EntityType = exports.AtomicProcessor = exports.JOB_TYPE_METADATA = exports.ENTITY_TYPE_METADATA = exports.ATOMIC_PROCESSOR_METADATA = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
/**
|
|
6
|
+
* Metadata keys for decorators
|
|
7
|
+
*/
|
|
8
|
+
exports.ATOMIC_PROCESSOR_METADATA = 'atomic:processor';
|
|
9
|
+
exports.ENTITY_TYPE_METADATA = 'atomic:entity-type';
|
|
10
|
+
exports.JOB_TYPE_METADATA = 'atomic:job-type';
|
|
11
|
+
/**
|
|
12
|
+
* @AtomicProcessor decorator
|
|
13
|
+
*
|
|
14
|
+
* Marks a method as an atomic job processor.
|
|
15
|
+
* Can be used on handler methods to auto-register them.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* @Injectable()
|
|
20
|
+
* export class MessageProcessor {
|
|
21
|
+
* @AtomicProcessor('send-message')
|
|
22
|
+
* async handleSendMessage(job: Job<IAtomicJobData>) {
|
|
23
|
+
* // Process the job
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const AtomicProcessor = (jobType) => {
|
|
29
|
+
return (0, common_1.SetMetadata)(exports.ATOMIC_PROCESSOR_METADATA, jobType);
|
|
30
|
+
};
|
|
31
|
+
exports.AtomicProcessor = AtomicProcessor;
|
|
32
|
+
/**
|
|
33
|
+
* @EntityType decorator
|
|
34
|
+
*
|
|
35
|
+
* Marks a class or method with an entity type for automatic registration.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* @Injectable()
|
|
40
|
+
* @EntityType('user')
|
|
41
|
+
* export class UserWorkerService {
|
|
42
|
+
* // All methods in this service are associated with 'user' entity type
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
const EntityType = (entityType) => {
|
|
47
|
+
return (0, common_1.SetMetadata)(exports.ENTITY_TYPE_METADATA, entityType);
|
|
48
|
+
};
|
|
49
|
+
exports.EntityType = EntityType;
|
|
50
|
+
/**
|
|
51
|
+
* @JobType decorator
|
|
52
|
+
*
|
|
53
|
+
* Specifies the job type for a processor method.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* @Injectable()
|
|
58
|
+
* export class TableProcessor {
|
|
59
|
+
* @JobType('make-bet')
|
|
60
|
+
* async handleMakeBet(job: Job) {
|
|
61
|
+
* // Process bet
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
const JobType = (jobType) => {
|
|
67
|
+
return (0, common_1.SetMetadata)(exports.JOB_TYPE_METADATA, jobType);
|
|
68
|
+
};
|
|
69
|
+
exports.JobType = JobType;
|
|
70
|
+
/**
|
|
71
|
+
* @InjectAtomicQueue decorator
|
|
72
|
+
*
|
|
73
|
+
* Custom parameter decorator for injecting a specific queue.
|
|
74
|
+
* Useful when you need direct access to a queue in a service.
|
|
75
|
+
*
|
|
76
|
+
* Note: This is a placeholder - actual implementation would use
|
|
77
|
+
* NestJS's custom parameter decorators with module injection.
|
|
78
|
+
*/
|
|
79
|
+
const InjectAtomicQueue = (entityType, entityId) => {
|
|
80
|
+
return (target, propertyKey, parameterIndex) => {
|
|
81
|
+
const existingParams = Reflect.getMetadata('atomic:inject-queue', target, propertyKey) || [];
|
|
82
|
+
existingParams.push({
|
|
83
|
+
type: entityType,
|
|
84
|
+
id: entityId,
|
|
85
|
+
index: parameterIndex,
|
|
86
|
+
});
|
|
87
|
+
Reflect.defineMetadata('atomic:inject-queue', existingParams, target, propertyKey);
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.InjectAtomicQueue = InjectAtomicQueue;
|
|
91
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators/decorators.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C;;GAEG;AACU,QAAA,yBAAyB,GAAG,kBAAkB,CAAC;AAC/C,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,eAAe,GAAG,CAAC,OAAe,EAAmB,EAAE;IAClE,OAAO,IAAA,oBAAW,EAAC,iCAAyB,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B;AAEF;;;;;;;;;;;;;GAaG;AACI,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAoC,EAAE;IACjF,OAAO,IAAA,oBAAW,EAAC,4BAAoB,EAAE,UAAU,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEF;;;;;;;;;;;;;;;GAeG;AACI,MAAM,OAAO,GAAG,CAAC,OAAe,EAAmB,EAAE;IAC1D,OAAO,IAAA,oBAAW,EAAC,yBAAiB,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AAEF;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAC/B,UAAkB,EAClB,QAAiB,EACG,EAAE;IACtB,OAAO,CACL,MAAc,EACd,WAAwC,EACxC,cAAsB,EACtB,EAAE;QACF,MAAM,cAAc,GAClB,OAAO,CAAC,WAAW,CAAC,qBAAqB,EAAE,MAAM,EAAE,WAAY,CAAC,IAAI,EAAE,CAAC;QAEzE,cAAc,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;QAEH,OAAO,CAAC,cAAc,CACpB,qBAAqB,EACrB,cAAc,EACd,MAAM,EACN,WAAY,CACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,iBAAiB,qBAyB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,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("./decorators"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Domain exports
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,+CAA6B"}
|