atomic-queues 1.6.1 → 2.0.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 +182 -411
- package/dist/cli/generators/json-schema.d.ts +3 -0
- package/dist/cli/generators/json-schema.d.ts.map +1 -0
- package/dist/cli/generators/json-schema.js +31 -0
- package/dist/cli/generators/json-schema.js.map +1 -0
- package/dist/cli/generators/typescript.d.ts +3 -0
- package/dist/cli/generators/typescript.d.ts.map +1 -0
- package/dist/cli/generators/typescript.js +62 -0
- package/dist/cli/generators/typescript.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +156 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/decorators/actor.decorators.d.ts +4 -0
- package/dist/decorators/actor.decorators.d.ts.map +1 -0
- package/dist/decorators/actor.decorators.js +32 -0
- package/dist/decorators/actor.decorators.js.map +1 -0
- package/dist/decorators/constants.d.ts +5 -12
- package/dist/decorators/constants.d.ts.map +1 -1
- package/dist/decorators/constants.js +10 -16
- package/dist/decorators/constants.js.map +1 -1
- package/dist/decorators/index.d.ts +4 -4
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +4 -4
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/interfaces.d.ts +18 -78
- package/dist/decorators/interfaces.d.ts.map +1 -1
- package/dist/decorators/metadata-readers.d.ts +5 -26
- package/dist/decorators/metadata-readers.d.ts.map +1 -1
- package/dist/decorators/metadata-readers.js +16 -33
- package/dist/decorators/metadata-readers.js.map +1 -1
- package/dist/decorators/schema.decorators.d.ts +2 -0
- package/dist/decorators/schema.decorators.d.ts.map +1 -0
- package/dist/decorators/schema.decorators.js +13 -0
- package/dist/decorators/schema.decorators.js.map +1 -0
- package/dist/domain/interfaces/config.interfaces.d.ts +52 -153
- package/dist/domain/interfaces/config.interfaces.d.ts.map +1 -1
- package/dist/domain/interfaces/index.d.ts +0 -7
- package/dist/domain/interfaces/index.d.ts.map +1 -1
- package/dist/domain/interfaces/index.js +0 -7
- package/dist/domain/interfaces/index.js.map +1 -1
- package/dist/domain/interfaces/job.interfaces.d.ts +32 -65
- package/dist/domain/interfaces/job.interfaces.d.ts.map +1 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -39
- package/dist/index.js.map +1 -1
- package/dist/module/atomic-queues.module.d.ts +0 -83
- package/dist/module/atomic-queues.module.d.ts.map +1 -1
- package/dist/module/atomic-queues.module.js +35 -134
- package/dist/module/atomic-queues.module.js.map +1 -1
- package/dist/services/actor-registry/actor-registry.service.d.ts +30 -0
- package/dist/services/actor-registry/actor-registry.service.d.ts.map +1 -0
- package/dist/services/actor-registry/actor-registry.service.js +186 -0
- package/dist/services/actor-registry/actor-registry.service.js.map +1 -0
- package/dist/services/actor-registry/index.d.ts +2 -0
- package/dist/services/actor-registry/index.d.ts.map +1 -0
- package/dist/services/actor-registry/index.js +18 -0
- package/dist/services/actor-registry/index.js.map +1 -0
- package/dist/services/actor-system/actor-system.service.d.ts +19 -0
- package/dist/services/actor-system/actor-system.service.d.ts.map +1 -0
- package/dist/services/actor-system/actor-system.service.js +86 -0
- package/dist/services/actor-system/actor-system.service.js.map +1 -0
- package/dist/services/actor-system/index.d.ts +2 -0
- package/dist/services/actor-system/index.d.ts.map +1 -0
- package/dist/services/{cron-manager → actor-system}/index.js +1 -1
- package/dist/services/actor-system/index.js.map +1 -0
- package/dist/services/command-discovery/command-discovery.service.d.ts +6 -53
- package/dist/services/command-discovery/command-discovery.service.d.ts.map +1 -1
- package/dist/services/command-discovery/command-discovery.service.js +0 -59
- package/dist/services/command-discovery/command-discovery.service.js.map +1 -1
- package/dist/services/constants.d.ts +2 -9
- package/dist/services/constants.d.ts.map +1 -1
- package/dist/services/constants.js +3 -10
- package/dist/services/constants.js.map +1 -1
- package/dist/services/executor-pool/executor-pool.service.d.ts +31 -0
- package/dist/services/executor-pool/executor-pool.service.d.ts.map +1 -0
- package/dist/services/executor-pool/executor-pool.service.js +147 -0
- package/dist/services/executor-pool/executor-pool.service.js.map +1 -0
- package/dist/services/executor-pool/index.d.ts +2 -0
- package/dist/services/executor-pool/index.d.ts.map +1 -0
- package/dist/services/{queue-manager → executor-pool}/index.js +1 -1
- package/dist/services/executor-pool/index.js.map +1 -0
- package/dist/services/gate/gate.service.d.ts +17 -0
- package/dist/services/gate/gate.service.d.ts.map +1 -0
- package/dist/services/gate/gate.service.js +66 -0
- package/dist/services/gate/gate.service.js.map +1 -0
- package/dist/services/gate/index.d.ts +2 -0
- package/dist/services/gate/index.d.ts.map +1 -0
- package/dist/services/{spawn-queue → gate}/index.js +1 -1
- package/dist/services/gate/index.js.map +1 -0
- package/dist/services/handler-executor/handler-executor.service.d.ts +32 -0
- package/dist/services/handler-executor/handler-executor.service.d.ts.map +1 -0
- package/dist/services/handler-executor/handler-executor.service.js +186 -0
- package/dist/services/handler-executor/handler-executor.service.js.map +1 -0
- package/dist/services/handler-executor/index.d.ts +2 -0
- package/dist/services/handler-executor/index.d.ts.map +1 -0
- package/dist/services/handler-executor/index.js +18 -0
- package/dist/services/handler-executor/index.js.map +1 -0
- package/dist/services/index.d.ts +11 -12
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +11 -12
- package/dist/services/index.js.map +1 -1
- package/dist/services/log/index.d.ts +2 -0
- package/dist/services/log/index.d.ts.map +1 -0
- package/dist/services/{index-manager → log}/index.js +1 -1
- package/dist/services/log/index.js.map +1 -0
- package/dist/services/log/log.service.d.ts +21 -0
- package/dist/services/log/log.service.d.ts.map +1 -0
- package/dist/services/log/log.service.js +92 -0
- package/dist/services/log/log.service.js.map +1 -0
- package/dist/services/queue-bus/index.d.ts +0 -4
- package/dist/services/queue-bus/index.d.ts.map +1 -1
- package/dist/services/queue-bus/index.js +0 -4
- package/dist/services/queue-bus/index.js.map +1 -1
- package/dist/services/queue-bus/queue-bus.service.d.ts +44 -198
- package/dist/services/queue-bus/queue-bus.service.d.ts.map +1 -1
- package/dist/services/queue-bus/queue-bus.service.js +103 -259
- package/dist/services/queue-bus/queue-bus.service.js.map +1 -1
- package/dist/services/queue-bus/queue-bus.utils.d.ts +0 -28
- package/dist/services/queue-bus/queue-bus.utils.d.ts.map +1 -1
- package/dist/services/queue-bus/queue-bus.utils.js +1 -41
- package/dist/services/queue-bus/queue-bus.utils.js.map +1 -1
- package/dist/services/registry/index.d.ts +4 -0
- package/dist/services/registry/index.d.ts.map +1 -0
- package/dist/services/{queue-events-manager → registry}/index.js +3 -1
- package/dist/services/registry/index.js.map +1 -0
- package/dist/services/registry/registry.service.d.ts +43 -0
- package/dist/services/registry/registry.service.d.ts.map +1 -0
- package/dist/services/registry/registry.service.js +379 -0
- package/dist/services/registry/registry.service.js.map +1 -0
- package/dist/services/registry/registry.types.d.ts +24 -0
- package/dist/services/registry/registry.types.d.ts.map +1 -0
- package/dist/{domain/interfaces/lock.interfaces.js → services/registry/registry.types.js} +1 -1
- package/dist/services/registry/registry.types.js.map +1 -0
- package/dist/services/registry/schema-converter.d.ts +2 -0
- package/dist/services/registry/schema-converter.d.ts.map +1 -0
- package/dist/services/registry/schema-converter.js +27 -0
- package/dist/services/registry/schema-converter.js.map +1 -0
- package/dist/services/result-collector/index.d.ts +2 -0
- package/dist/services/result-collector/index.d.ts.map +1 -0
- package/dist/services/result-collector/index.js +18 -0
- package/dist/services/result-collector/index.js.map +1 -0
- package/dist/services/result-collector/result-collector.service.d.ts +17 -0
- package/dist/services/result-collector/result-collector.service.d.ts.map +1 -0
- package/dist/services/result-collector/result-collector.service.js +92 -0
- package/dist/services/result-collector/result-collector.service.js.map +1 -0
- package/dist/services/scheduler/index.d.ts +2 -0
- package/dist/services/scheduler/index.d.ts.map +1 -0
- package/dist/services/{job-processor → scheduler}/index.js +1 -1
- package/dist/services/scheduler/index.js.map +1 -0
- package/dist/services/scheduler/scheduler.service.d.ts +17 -0
- package/dist/services/scheduler/scheduler.service.d.ts.map +1 -0
- package/dist/services/scheduler/scheduler.service.js +116 -0
- package/dist/services/scheduler/scheduler.service.js.map +1 -0
- package/dist/services/shutdown/index.d.ts +2 -0
- package/dist/services/shutdown/index.d.ts.map +1 -0
- package/dist/services/shutdown/index.js +18 -0
- package/dist/services/shutdown/index.js.map +1 -0
- package/dist/services/shutdown/shutdown.service.d.ts +8 -0
- package/dist/services/shutdown/shutdown.service.d.ts.map +1 -0
- package/dist/services/shutdown/shutdown.service.js +29 -0
- package/dist/services/shutdown/shutdown.service.js.map +1 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/naming.utils.d.ts +0 -16
- package/dist/utils/naming.utils.d.ts.map +1 -1
- package/dist/utils/naming.utils.js +0 -29
- package/dist/utils/naming.utils.js.map +1 -1
- package/package.json +19 -11
- package/dist/decorators/legacy.decorators.d.ts +0 -36
- package/dist/decorators/legacy.decorators.d.ts.map +0 -1
- package/dist/decorators/legacy.decorators.js +0 -61
- package/dist/decorators/legacy.decorators.js.map +0 -1
- package/dist/decorators/scaler.decorators.d.ts +0 -65
- package/dist/decorators/scaler.decorators.d.ts.map +0 -1
- package/dist/decorators/scaler.decorators.js +0 -103
- package/dist/decorators/scaler.decorators.js.map +0 -1
- package/dist/decorators/type-guards.d.ts +0 -18
- package/dist/decorators/type-guards.d.ts.map +0 -1
- package/dist/decorators/type-guards.js +0 -32
- package/dist/decorators/type-guards.js.map +0 -1
- package/dist/decorators/worker.decorators.d.ts +0 -58
- package/dist/decorators/worker.decorators.d.ts.map +0 -1
- package/dist/decorators/worker.decorators.js +0 -92
- package/dist/decorators/worker.decorators.js.map +0 -1
- package/dist/domain/interfaces/event.interfaces.d.ts +0 -71
- package/dist/domain/interfaces/event.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/event.interfaces.js +0 -3
- package/dist/domain/interfaces/event.interfaces.js.map +0 -1
- package/dist/domain/interfaces/index-tracking.interfaces.d.ts +0 -69
- package/dist/domain/interfaces/index-tracking.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/index-tracking.interfaces.js +0 -3
- package/dist/domain/interfaces/index-tracking.interfaces.js.map +0 -1
- package/dist/domain/interfaces/lock.interfaces.d.ts +0 -54
- package/dist/domain/interfaces/lock.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/lock.interfaces.js.map +0 -1
- package/dist/domain/interfaces/process.interfaces.d.ts +0 -44
- package/dist/domain/interfaces/process.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/process.interfaces.js +0 -3
- package/dist/domain/interfaces/process.interfaces.js.map +0 -1
- package/dist/domain/interfaces/queue.interfaces.d.ts +0 -46
- package/dist/domain/interfaces/queue.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/queue.interfaces.js +0 -3
- package/dist/domain/interfaces/queue.interfaces.js.map +0 -1
- package/dist/domain/interfaces/scaling.interfaces.d.ts +0 -62
- package/dist/domain/interfaces/scaling.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/scaling.interfaces.js +0 -3
- package/dist/domain/interfaces/scaling.interfaces.js.map +0 -1
- package/dist/domain/interfaces/worker.interfaces.d.ts +0 -120
- package/dist/domain/interfaces/worker.interfaces.d.ts.map +0 -1
- package/dist/domain/interfaces/worker.interfaces.js +0 -3
- package/dist/domain/interfaces/worker.interfaces.js.map +0 -1
- package/dist/services/cron-manager/cron-manager.service.d.ts +0 -199
- package/dist/services/cron-manager/cron-manager.service.d.ts.map +0 -1
- package/dist/services/cron-manager/cron-manager.service.js +0 -583
- package/dist/services/cron-manager/cron-manager.service.js.map +0 -1
- package/dist/services/cron-manager/index.d.ts +0 -2
- package/dist/services/cron-manager/index.d.ts.map +0 -1
- package/dist/services/cron-manager/index.js.map +0 -1
- package/dist/services/index-manager/index-manager.service.d.ts +0 -142
- package/dist/services/index-manager/index-manager.service.d.ts.map +0 -1
- package/dist/services/index-manager/index-manager.service.js +0 -325
- package/dist/services/index-manager/index-manager.service.js.map +0 -1
- package/dist/services/index-manager/index.d.ts +0 -2
- package/dist/services/index-manager/index.d.ts.map +0 -1
- package/dist/services/index-manager/index.js.map +0 -1
- package/dist/services/job-processor/index.d.ts +0 -2
- package/dist/services/job-processor/index.d.ts.map +0 -1
- package/dist/services/job-processor/index.js.map +0 -1
- package/dist/services/job-processor/job-processor.service.d.ts +0 -156
- package/dist/services/job-processor/job-processor.service.d.ts.map +0 -1
- package/dist/services/job-processor/job-processor.service.js +0 -331
- package/dist/services/job-processor/job-processor.service.js.map +0 -1
- package/dist/services/processor-discovery/decorator-discovery.service.d.ts +0 -40
- package/dist/services/processor-discovery/decorator-discovery.service.d.ts.map +0 -1
- package/dist/services/processor-discovery/decorator-discovery.service.js +0 -191
- package/dist/services/processor-discovery/decorator-discovery.service.js.map +0 -1
- package/dist/services/processor-discovery/index.d.ts +0 -6
- package/dist/services/processor-discovery/index.d.ts.map +0 -1
- package/dist/services/processor-discovery/index.js +0 -22
- package/dist/services/processor-discovery/index.js.map +0 -1
- package/dist/services/processor-discovery/processor-discovery.service.d.ts +0 -98
- package/dist/services/processor-discovery/processor-discovery.service.d.ts.map +0 -1
- package/dist/services/processor-discovery/processor-discovery.service.js +0 -258
- package/dist/services/processor-discovery/processor-discovery.service.js.map +0 -1
- package/dist/services/processor-discovery/processor-registry.d.ts +0 -58
- package/dist/services/processor-discovery/processor-registry.d.ts.map +0 -1
- package/dist/services/processor-discovery/processor-registry.js +0 -74
- package/dist/services/processor-discovery/processor-registry.js.map +0 -1
- package/dist/services/processor-discovery/scaling-registration.service.d.ts +0 -60
- package/dist/services/processor-discovery/scaling-registration.service.d.ts.map +0 -1
- package/dist/services/processor-discovery/scaling-registration.service.js +0 -261
- package/dist/services/processor-discovery/scaling-registration.service.js.map +0 -1
- package/dist/services/processor-discovery/worker-factory.service.d.ts +0 -54
- package/dist/services/processor-discovery/worker-factory.service.d.ts.map +0 -1
- package/dist/services/processor-discovery/worker-factory.service.js +0 -185
- package/dist/services/processor-discovery/worker-factory.service.js.map +0 -1
- package/dist/services/queue-bus/entity-target.d.ts +0 -58
- package/dist/services/queue-bus/entity-target.d.ts.map +0 -1
- package/dist/services/queue-bus/entity-target.js +0 -109
- package/dist/services/queue-bus/entity-target.js.map +0 -1
- package/dist/services/queue-bus/queue-bus.types.d.ts +0 -40
- package/dist/services/queue-bus/queue-bus.types.d.ts.map +0 -1
- package/dist/services/queue-bus/queue-bus.types.js +0 -3
- package/dist/services/queue-bus/queue-bus.types.js.map +0 -1
- package/dist/services/queue-bus/queue-target.d.ts +0 -61
- package/dist/services/queue-bus/queue-target.d.ts.map +0 -1
- package/dist/services/queue-bus/queue-target.js +0 -123
- package/dist/services/queue-bus/queue-target.js.map +0 -1
- package/dist/services/queue-events-manager/index.d.ts +0 -2
- package/dist/services/queue-events-manager/index.d.ts.map +0 -1
- package/dist/services/queue-events-manager/index.js.map +0 -1
- package/dist/services/queue-events-manager/queue-events-manager.service.d.ts +0 -120
- package/dist/services/queue-events-manager/queue-events-manager.service.d.ts.map +0 -1
- package/dist/services/queue-events-manager/queue-events-manager.service.js +0 -343
- package/dist/services/queue-events-manager/queue-events-manager.service.js.map +0 -1
- package/dist/services/queue-manager/index.d.ts +0 -2
- package/dist/services/queue-manager/index.d.ts.map +0 -1
- package/dist/services/queue-manager/index.js.map +0 -1
- package/dist/services/queue-manager/queue-manager.service.d.ts +0 -148
- package/dist/services/queue-manager/queue-manager.service.d.ts.map +0 -1
- package/dist/services/queue-manager/queue-manager.service.js +0 -348
- package/dist/services/queue-manager/queue-manager.service.js.map +0 -1
- package/dist/services/resource-lock/index.d.ts +0 -2
- package/dist/services/resource-lock/index.d.ts.map +0 -1
- package/dist/services/resource-lock/index.js +0 -18
- package/dist/services/resource-lock/index.js.map +0 -1
- package/dist/services/resource-lock/resource-lock.service.d.ts +0 -120
- package/dist/services/resource-lock/resource-lock.service.d.ts.map +0 -1
- package/dist/services/resource-lock/resource-lock.service.js +0 -367
- package/dist/services/resource-lock/resource-lock.service.js.map +0 -1
- package/dist/services/service-queue/index.d.ts +0 -3
- package/dist/services/service-queue/index.d.ts.map +0 -1
- package/dist/services/service-queue/index.js +0 -19
- package/dist/services/service-queue/index.js.map +0 -1
- package/dist/services/service-queue/service-queue.service.d.ts +0 -199
- package/dist/services/service-queue/service-queue.service.d.ts.map +0 -1
- package/dist/services/service-queue/service-queue.service.js +0 -617
- package/dist/services/service-queue/service-queue.service.js.map +0 -1
- package/dist/services/service-queue/service-queue.types.d.ts +0 -32
- package/dist/services/service-queue/service-queue.types.d.ts.map +0 -1
- package/dist/services/service-queue/service-queue.types.js +0 -27
- package/dist/services/service-queue/service-queue.types.js.map +0 -1
- package/dist/services/shutdown-state/index.d.ts +0 -2
- package/dist/services/shutdown-state/index.d.ts.map +0 -1
- package/dist/services/shutdown-state/index.js +0 -18
- package/dist/services/shutdown-state/index.js.map +0 -1
- package/dist/services/shutdown-state/shutdown-state.service.d.ts +0 -69
- package/dist/services/shutdown-state/shutdown-state.service.d.ts.map +0 -1
- package/dist/services/shutdown-state/shutdown-state.service.js +0 -127
- package/dist/services/shutdown-state/shutdown-state.service.js.map +0 -1
- package/dist/services/spawn-queue/index.d.ts +0 -2
- package/dist/services/spawn-queue/index.d.ts.map +0 -1
- package/dist/services/spawn-queue/index.js.map +0 -1
- package/dist/services/spawn-queue/spawn-queue.service.d.ts +0 -119
- package/dist/services/spawn-queue/spawn-queue.service.d.ts.map +0 -1
- package/dist/services/spawn-queue/spawn-queue.service.js +0 -273
- package/dist/services/spawn-queue/spawn-queue.service.js.map +0 -1
- package/dist/services/worker-manager/index.d.ts +0 -2
- package/dist/services/worker-manager/index.d.ts.map +0 -1
- package/dist/services/worker-manager/index.js +0 -18
- package/dist/services/worker-manager/index.js.map +0 -1
- package/dist/services/worker-manager/worker-manager.service.d.ts +0 -221
- package/dist/services/worker-manager/worker-manager.service.d.ts.map +0 -1
- package/dist/services/worker-manager/worker-manager.service.js +0 -591
- package/dist/services/worker-manager/worker-manager.service.js.map +0 -1
- package/dist/utils/helpers.d.ts +0 -5
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/helpers.js +0 -21
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/job.utils.d.ts +0 -50
- package/dist/utils/job.utils.d.ts.map +0 -1
- package/dist/utils/job.utils.js +0 -89
- package/dist/utils/job.utils.js.map +0 -1
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import Redis from 'ioredis';
|
|
2
|
-
import { IIndexManager, IAtomicQueuesModuleConfig } from '../../domain';
|
|
3
|
-
/**
|
|
4
|
-
* IndexManagerService
|
|
5
|
-
*
|
|
6
|
-
* Manages Redis indices for tracking jobs, workers, queues, and their states.
|
|
7
|
-
* Implements patterns from Whatsapi for tracking message queues, worker deaths,
|
|
8
|
-
* and queue lifecycle.
|
|
9
|
-
*
|
|
10
|
-
* Key Features:
|
|
11
|
-
* - Job indexing per entity
|
|
12
|
-
* - Worker death tracking for graceful termination
|
|
13
|
-
* - Queue lifecycle tracking
|
|
14
|
-
* - Entity-based aggregations
|
|
15
|
-
*
|
|
16
|
-
* Redis Key Patterns:
|
|
17
|
-
* - jobs-index:{entityType}:{entityId}:jobs -> Set of job IDs
|
|
18
|
-
* - workerDeaths-index:{entityType}:{entityId}:deaths -> Set of death signal IDs
|
|
19
|
-
* - queue-index:{entityType}:{entityId}:queue -> Queue existence marker
|
|
20
|
-
* - queueDeaths-index:{entityType}:{entityId}:deaths -> Queue death signals
|
|
21
|
-
*/
|
|
22
|
-
export declare class IndexManagerService implements IIndexManager {
|
|
23
|
-
private readonly redis;
|
|
24
|
-
private readonly config;
|
|
25
|
-
private readonly logger;
|
|
26
|
-
private readonly keyPrefix;
|
|
27
|
-
constructor(redis: Redis, config: IAtomicQueuesModuleConfig);
|
|
28
|
-
/**
|
|
29
|
-
* Index a job for an entity.
|
|
30
|
-
*/
|
|
31
|
-
indexJob(entityType: string, entityId: string, jobId: string): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Remove job index.
|
|
34
|
-
*/
|
|
35
|
-
removeJobIndex(entityType: string, entityId: string, jobId: string): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Get all job IDs for an entity.
|
|
38
|
-
*/
|
|
39
|
-
getEntityJobs(entityType: string, entityId: string): Promise<string[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Get all entities with jobs and their job counts.
|
|
42
|
-
*/
|
|
43
|
-
getEntitiesWithJobs(entityType: string): Promise<Record<string, number>>;
|
|
44
|
-
/**
|
|
45
|
-
* Get job count for an entity.
|
|
46
|
-
*/
|
|
47
|
-
getEntityJobCount(entityType: string, entityId: string): Promise<number>;
|
|
48
|
-
/**
|
|
49
|
-
* Clear all job indices for an entity.
|
|
50
|
-
*/
|
|
51
|
-
clearEntityJobs(entityType: string, entityId: string): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Index a worker death signal.
|
|
54
|
-
*/
|
|
55
|
-
indexWorkerDeath(entityType: string, entityId: string, deathId: string): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Remove worker death index.
|
|
58
|
-
*/
|
|
59
|
-
removeWorkerDeathIndex(entityType: string, entityId: string, deathId: string): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Get queued worker deaths for an entity.
|
|
62
|
-
*/
|
|
63
|
-
getQueuedWorkerDeaths(entityType: string, entityId: string): Promise<string[]>;
|
|
64
|
-
/**
|
|
65
|
-
* Get all entities with queued worker deaths.
|
|
66
|
-
*/
|
|
67
|
-
getEntitiesWithQueuedWorkerDeaths(entityType: string): Promise<string[]>;
|
|
68
|
-
/**
|
|
69
|
-
* Clear all worker death indices for an entity.
|
|
70
|
-
*/
|
|
71
|
-
clearEntityWorkerDeaths(entityType: string, entityId: string): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Index entity queue existence.
|
|
74
|
-
*/
|
|
75
|
-
indexEntityQueue(entityType: string, entityId: string): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Remove entity queue index.
|
|
78
|
-
*/
|
|
79
|
-
removeEntityQueueIndex(entityType: string, entityId: string): Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* Get all entities with active queues.
|
|
82
|
-
*/
|
|
83
|
-
getEntitiesWithQueues(entityType: string): Promise<string[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Check if entity has an active queue.
|
|
86
|
-
*/
|
|
87
|
-
hasEntityQueue(entityType: string, entityId: string): Promise<boolean>;
|
|
88
|
-
/**
|
|
89
|
-
* Index a queue death signal.
|
|
90
|
-
*/
|
|
91
|
-
indexQueueDeath(entityType: string, entityId: string): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Remove queue death index.
|
|
94
|
-
*/
|
|
95
|
-
removeQueueDeathIndex(entityType: string, entityId: string): Promise<void>;
|
|
96
|
-
/**
|
|
97
|
-
* Get all entities with queued queue deaths.
|
|
98
|
-
*/
|
|
99
|
-
getEntitiesWithQueuedQueueDeaths(entityType: string): Promise<string[]>;
|
|
100
|
-
/**
|
|
101
|
-
* Index a worker creation request.
|
|
102
|
-
*/
|
|
103
|
-
indexWorkerCreationRequest(entityType: string, entityId: string): Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Decrement worker creation request count.
|
|
106
|
-
*/
|
|
107
|
-
decrementWorkerCreationRequest(entityType: string, entityId: string): Promise<void>;
|
|
108
|
-
/**
|
|
109
|
-
* Get worker creation request count.
|
|
110
|
-
*/
|
|
111
|
-
getWorkerCreationRequestCount(entityType: string, entityId: string): Promise<number>;
|
|
112
|
-
/**
|
|
113
|
-
* Clear worker creation request index.
|
|
114
|
-
*/
|
|
115
|
-
clearWorkerCreationRequests(entityType: string, entityId: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Clean up all indices for an entity.
|
|
118
|
-
* Call this when completely removing an entity from the system.
|
|
119
|
-
*/
|
|
120
|
-
cleanupEntityIndices(entityType: string, entityId: string): Promise<void>;
|
|
121
|
-
/**
|
|
122
|
-
* Get the key for job index.
|
|
123
|
-
*/
|
|
124
|
-
private getJobIndexKey;
|
|
125
|
-
/**
|
|
126
|
-
* Get the key for worker death index.
|
|
127
|
-
*/
|
|
128
|
-
private getWorkerDeathIndexKey;
|
|
129
|
-
/**
|
|
130
|
-
* Get the key for queue index.
|
|
131
|
-
*/
|
|
132
|
-
private getQueueIndexKey;
|
|
133
|
-
/**
|
|
134
|
-
* Get the key for queue death index.
|
|
135
|
-
*/
|
|
136
|
-
private getQueueDeathIndexKey;
|
|
137
|
-
/**
|
|
138
|
-
* Extract entity ID from a Redis key.
|
|
139
|
-
*/
|
|
140
|
-
private extractEntityIdFromKey;
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=index-manager.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-manager.service.d.ts","sourceRoot":"","sources":["../../../src/services/index-manager/index-manager.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBACa,mBAAoB,YAAW,aAAa;IAKxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAEnD,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAGa,KAAK,EAAE,KAAK,EAEzC,MAAM,EAAE,yBAAyB;IASpD;;OAEG;IACG,QAAQ,CACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAShB;;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-
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
var IndexManagerService_1;
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.IndexManagerService = void 0;
|
|
20
|
-
const common_1 = require("@nestjs/common");
|
|
21
|
-
const ioredis_1 = __importDefault(require("ioredis"));
|
|
22
|
-
const utils_1 = require("../../utils");
|
|
23
|
-
const constants_1 = require("../constants");
|
|
24
|
-
/**
|
|
25
|
-
* IndexManagerService
|
|
26
|
-
*
|
|
27
|
-
* Manages Redis indices for tracking jobs, workers, queues, and their states.
|
|
28
|
-
* Implements patterns from Whatsapi for tracking message queues, worker deaths,
|
|
29
|
-
* and queue lifecycle.
|
|
30
|
-
*
|
|
31
|
-
* Key Features:
|
|
32
|
-
* - Job indexing per entity
|
|
33
|
-
* - Worker death tracking for graceful termination
|
|
34
|
-
* - Queue lifecycle tracking
|
|
35
|
-
* - Entity-based aggregations
|
|
36
|
-
*
|
|
37
|
-
* Redis Key Patterns:
|
|
38
|
-
* - jobs-index:{entityType}:{entityId}:jobs -> Set of job IDs
|
|
39
|
-
* - workerDeaths-index:{entityType}:{entityId}:deaths -> Set of death signal IDs
|
|
40
|
-
* - queue-index:{entityType}:{entityId}:queue -> Queue existence marker
|
|
41
|
-
* - queueDeaths-index:{entityType}:{entityId}:deaths -> Queue death signals
|
|
42
|
-
*/
|
|
43
|
-
let IndexManagerService = IndexManagerService_1 = class IndexManagerService {
|
|
44
|
-
constructor(redis, config) {
|
|
45
|
-
this.redis = redis;
|
|
46
|
-
this.config = config;
|
|
47
|
-
this.logger = new common_1.Logger(IndexManagerService_1.name);
|
|
48
|
-
this.keyPrefix = (0, utils_1.resolveKeyPrefix)(config);
|
|
49
|
-
}
|
|
50
|
-
// =========================================================================
|
|
51
|
-
// JOB INDEXING
|
|
52
|
-
// =========================================================================
|
|
53
|
-
/**
|
|
54
|
-
* Index a job for an entity.
|
|
55
|
-
*/
|
|
56
|
-
async indexJob(entityType, entityId, jobId) {
|
|
57
|
-
const key = this.getJobIndexKey(entityType, entityId);
|
|
58
|
-
const member = `job:${entityType}:${entityId}:${jobId}`;
|
|
59
|
-
await this.redis.sadd(key, member);
|
|
60
|
-
this.logger.debug(`Indexed job ${jobId} for ${entityType}/${entityId}`);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Remove job index.
|
|
64
|
-
*/
|
|
65
|
-
async removeJobIndex(entityType, entityId, jobId) {
|
|
66
|
-
const key = this.getJobIndexKey(entityType, entityId);
|
|
67
|
-
const member = `job:${entityType}:${entityId}:${jobId}`;
|
|
68
|
-
await this.redis.srem(key, member);
|
|
69
|
-
this.logger.debug(`Removed job index ${jobId} for ${entityType}/${entityId}`);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get all job IDs for an entity.
|
|
73
|
-
*/
|
|
74
|
-
async getEntityJobs(entityType, entityId) {
|
|
75
|
-
const key = this.getJobIndexKey(entityType, entityId);
|
|
76
|
-
const members = await this.redis.smembers(key);
|
|
77
|
-
// Extract job IDs from the full member string
|
|
78
|
-
return members.map((m) => m.split(':').pop());
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get all entities with jobs and their job counts.
|
|
82
|
-
*/
|
|
83
|
-
async getEntitiesWithJobs(entityType) {
|
|
84
|
-
const pattern = `${this.keyPrefix}:jobs-index:${entityType}:*:jobs`;
|
|
85
|
-
const keys = await (0, utils_1.scanKeys)(this.redis, pattern);
|
|
86
|
-
const result = {};
|
|
87
|
-
for (const key of keys) {
|
|
88
|
-
const entityId = this.extractEntityIdFromKey(key, entityType);
|
|
89
|
-
if (entityId) {
|
|
90
|
-
const count = await this.redis.scard(key);
|
|
91
|
-
result[entityId] = count;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get job count for an entity.
|
|
98
|
-
*/
|
|
99
|
-
async getEntityJobCount(entityType, entityId) {
|
|
100
|
-
const key = this.getJobIndexKey(entityType, entityId);
|
|
101
|
-
return this.redis.scard(key);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Clear all job indices for an entity.
|
|
105
|
-
*/
|
|
106
|
-
async clearEntityJobs(entityType, entityId) {
|
|
107
|
-
const key = this.getJobIndexKey(entityType, entityId);
|
|
108
|
-
await this.redis.del(key);
|
|
109
|
-
this.logger.debug(`Cleared all job indices for ${entityType}/${entityId}`);
|
|
110
|
-
}
|
|
111
|
-
// =========================================================================
|
|
112
|
-
// WORKER DEATH INDEXING
|
|
113
|
-
// =========================================================================
|
|
114
|
-
/**
|
|
115
|
-
* Index a worker death signal.
|
|
116
|
-
*/
|
|
117
|
-
async indexWorkerDeath(entityType, entityId, deathId) {
|
|
118
|
-
const key = this.getWorkerDeathIndexKey(entityType, entityId);
|
|
119
|
-
const member = `death:${entityType}:${entityId}:${deathId}`;
|
|
120
|
-
await this.redis.sadd(key, member);
|
|
121
|
-
this.logger.debug(`Indexed worker death ${deathId} for ${entityType}/${entityId}`);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Remove worker death index.
|
|
125
|
-
*/
|
|
126
|
-
async removeWorkerDeathIndex(entityType, entityId, deathId) {
|
|
127
|
-
const key = this.getWorkerDeathIndexKey(entityType, entityId);
|
|
128
|
-
const member = `death:${entityType}:${entityId}:${deathId}`;
|
|
129
|
-
await this.redis.srem(key, member);
|
|
130
|
-
this.logger.debug(`Removed worker death index ${deathId} for ${entityType}/${entityId}`);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get queued worker deaths for an entity.
|
|
134
|
-
*/
|
|
135
|
-
async getQueuedWorkerDeaths(entityType, entityId) {
|
|
136
|
-
const key = this.getWorkerDeathIndexKey(entityType, entityId);
|
|
137
|
-
const members = await this.redis.smembers(key);
|
|
138
|
-
return members.map((m) => m.split(':').pop());
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Get all entities with queued worker deaths.
|
|
142
|
-
*/
|
|
143
|
-
async getEntitiesWithQueuedWorkerDeaths(entityType) {
|
|
144
|
-
const pattern = `${this.keyPrefix}:workerDeaths-index:${entityType}:*:deaths`;
|
|
145
|
-
const keys = await (0, utils_1.scanKeys)(this.redis, pattern);
|
|
146
|
-
return keys
|
|
147
|
-
.map((key) => this.extractEntityIdFromKey(key, entityType))
|
|
148
|
-
.filter((id) => id !== null);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Clear all worker death indices for an entity.
|
|
152
|
-
*/
|
|
153
|
-
async clearEntityWorkerDeaths(entityType, entityId) {
|
|
154
|
-
const key = this.getWorkerDeathIndexKey(entityType, entityId);
|
|
155
|
-
await this.redis.del(key);
|
|
156
|
-
this.logger.debug(`Cleared all worker death indices for ${entityType}/${entityId}`);
|
|
157
|
-
}
|
|
158
|
-
// =========================================================================
|
|
159
|
-
// QUEUE INDEXING
|
|
160
|
-
// =========================================================================
|
|
161
|
-
/**
|
|
162
|
-
* Index entity queue existence.
|
|
163
|
-
*/
|
|
164
|
-
async indexEntityQueue(entityType, entityId) {
|
|
165
|
-
const indexKey = this.getQueueIndexKey(entityType);
|
|
166
|
-
const member = `queue:${entityType}:${entityId}`;
|
|
167
|
-
await this.redis.sadd(indexKey, member);
|
|
168
|
-
this.logger.debug(`Indexed queue for ${entityType}/${entityId}`);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Remove entity queue index.
|
|
172
|
-
*/
|
|
173
|
-
async removeEntityQueueIndex(entityType, entityId) {
|
|
174
|
-
const indexKey = this.getQueueIndexKey(entityType);
|
|
175
|
-
const member = `queue:${entityType}:${entityId}`;
|
|
176
|
-
await this.redis.srem(indexKey, member);
|
|
177
|
-
this.logger.debug(`Removed queue index for ${entityType}/${entityId}`);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Get all entities with active queues.
|
|
181
|
-
*/
|
|
182
|
-
async getEntitiesWithQueues(entityType) {
|
|
183
|
-
const indexKey = this.getQueueIndexKey(entityType);
|
|
184
|
-
const members = await this.redis.smembers(indexKey);
|
|
185
|
-
return members.map((m) => m.split(':').pop());
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Check if entity has an active queue.
|
|
189
|
-
*/
|
|
190
|
-
async hasEntityQueue(entityType, entityId) {
|
|
191
|
-
const indexKey = this.getQueueIndexKey(entityType);
|
|
192
|
-
const member = `queue:${entityType}:${entityId}`;
|
|
193
|
-
const isMember = await this.redis.sismember(indexKey, member);
|
|
194
|
-
return isMember === 1;
|
|
195
|
-
}
|
|
196
|
-
// =========================================================================
|
|
197
|
-
// QUEUE DEATH INDEXING
|
|
198
|
-
// =========================================================================
|
|
199
|
-
/**
|
|
200
|
-
* Index a queue death signal.
|
|
201
|
-
*/
|
|
202
|
-
async indexQueueDeath(entityType, entityId) {
|
|
203
|
-
const key = this.getQueueDeathIndexKey(entityType);
|
|
204
|
-
const member = `death:${entityType}:${entityId}`;
|
|
205
|
-
await this.redis.sadd(key, member);
|
|
206
|
-
this.logger.debug(`Indexed queue death for ${entityType}/${entityId}`);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Remove queue death index.
|
|
210
|
-
*/
|
|
211
|
-
async removeQueueDeathIndex(entityType, entityId) {
|
|
212
|
-
const key = this.getQueueDeathIndexKey(entityType);
|
|
213
|
-
const member = `death:${entityType}:${entityId}`;
|
|
214
|
-
await this.redis.srem(key, member);
|
|
215
|
-
this.logger.debug(`Removed queue death index for ${entityType}/${entityId}`);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Get all entities with queued queue deaths.
|
|
219
|
-
*/
|
|
220
|
-
async getEntitiesWithQueuedQueueDeaths(entityType) {
|
|
221
|
-
const key = this.getQueueDeathIndexKey(entityType);
|
|
222
|
-
const members = await this.redis.smembers(key);
|
|
223
|
-
return members.map((m) => m.split(':').pop());
|
|
224
|
-
}
|
|
225
|
-
// =========================================================================
|
|
226
|
-
// WORKER CREATION REQUEST TRACKING
|
|
227
|
-
// =========================================================================
|
|
228
|
-
/**
|
|
229
|
-
* Index a worker creation request.
|
|
230
|
-
*/
|
|
231
|
-
async indexWorkerCreationRequest(entityType, entityId) {
|
|
232
|
-
const key = `${this.keyPrefix}:worker-creation:${entityType}:${entityId}`;
|
|
233
|
-
await this.redis.incr(key);
|
|
234
|
-
await this.redis.expire(key, 60); // TTL for cleanup
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Decrement worker creation request count.
|
|
238
|
-
*/
|
|
239
|
-
async decrementWorkerCreationRequest(entityType, entityId) {
|
|
240
|
-
const key = `${this.keyPrefix}:worker-creation:${entityType}:${entityId}`;
|
|
241
|
-
const current = await this.redis.get(key);
|
|
242
|
-
if (current && parseInt(current, 10) > 0) {
|
|
243
|
-
await this.redis.decr(key);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Get worker creation request count.
|
|
248
|
-
*/
|
|
249
|
-
async getWorkerCreationRequestCount(entityType, entityId) {
|
|
250
|
-
const key = `${this.keyPrefix}:worker-creation:${entityType}:${entityId}`;
|
|
251
|
-
const count = await this.redis.get(key);
|
|
252
|
-
return count ? parseInt(count, 10) : 0;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Clear worker creation request index.
|
|
256
|
-
*/
|
|
257
|
-
async clearWorkerCreationRequests(entityType, entityId) {
|
|
258
|
-
const key = `${this.keyPrefix}:worker-creation:${entityType}:${entityId}`;
|
|
259
|
-
await this.redis.del(key);
|
|
260
|
-
}
|
|
261
|
-
// =========================================================================
|
|
262
|
-
// UTILITY METHODS
|
|
263
|
-
// =========================================================================
|
|
264
|
-
/**
|
|
265
|
-
* Clean up all indices for an entity.
|
|
266
|
-
* Call this when completely removing an entity from the system.
|
|
267
|
-
*/
|
|
268
|
-
async cleanupEntityIndices(entityType, entityId) {
|
|
269
|
-
await Promise.all([
|
|
270
|
-
this.clearEntityJobs(entityType, entityId),
|
|
271
|
-
this.clearEntityWorkerDeaths(entityType, entityId),
|
|
272
|
-
this.removeEntityQueueIndex(entityType, entityId),
|
|
273
|
-
this.removeQueueDeathIndex(entityType, entityId),
|
|
274
|
-
this.clearWorkerCreationRequests(entityType, entityId),
|
|
275
|
-
]);
|
|
276
|
-
this.logger.debug(`Cleaned up all indices for ${entityType}/${entityId}`);
|
|
277
|
-
}
|
|
278
|
-
// =========================================================================
|
|
279
|
-
// PRIVATE METHODS
|
|
280
|
-
// =========================================================================
|
|
281
|
-
/**
|
|
282
|
-
* Get the key for job index.
|
|
283
|
-
*/
|
|
284
|
-
getJobIndexKey(entityType, entityId) {
|
|
285
|
-
return `${this.keyPrefix}:jobs-index:${entityType}:${entityId}:jobs`;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Get the key for worker death index.
|
|
289
|
-
*/
|
|
290
|
-
getWorkerDeathIndexKey(entityType, entityId) {
|
|
291
|
-
return `${this.keyPrefix}:workerDeaths-index:${entityType}:${entityId}:deaths`;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Get the key for queue index.
|
|
295
|
-
*/
|
|
296
|
-
getQueueIndexKey(entityType) {
|
|
297
|
-
return `${this.keyPrefix}:queue-index:${entityType}:queues`;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Get the key for queue death index.
|
|
301
|
-
*/
|
|
302
|
-
getQueueDeathIndexKey(entityType) {
|
|
303
|
-
return `${this.keyPrefix}:queueDeaths-index:${entityType}:deaths`;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Extract entity ID from a Redis key.
|
|
307
|
-
*/
|
|
308
|
-
extractEntityIdFromKey(key, entityType) {
|
|
309
|
-
// Key format: {prefix}:{indexType}:{entityType}:{entityId}:{suffix}
|
|
310
|
-
const parts = key.split(':');
|
|
311
|
-
const entityTypeIndex = parts.indexOf(entityType);
|
|
312
|
-
if (entityTypeIndex !== -1 && parts.length > entityTypeIndex + 1) {
|
|
313
|
-
return parts[entityTypeIndex + 1];
|
|
314
|
-
}
|
|
315
|
-
return null;
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
exports.IndexManagerService = IndexManagerService;
|
|
319
|
-
exports.IndexManagerService = IndexManagerService = IndexManagerService_1 = __decorate([
|
|
320
|
-
(0, common_1.Injectable)(),
|
|
321
|
-
__param(0, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_REDIS)),
|
|
322
|
-
__param(1, (0, common_1.Inject)(constants_1.ATOMIC_QUEUES_CONFIG)),
|
|
323
|
-
__metadata("design:paramtypes", [ioredis_1.default, Object])
|
|
324
|
-
], IndexManagerService);
|
|
325
|
-
//# sourceMappingURL=index-manager.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-manager.service.js","sourceRoot":"","sources":["../../../src/services/index-manager/index-manager.service.ts"],"names":[],"mappings":";;;;;;;;;;;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,CAAC,UAAkB;QAC9C,OAAO,GAAG,IAAI,CAAC,SAAS,sBAAsB,UAAU,SAAS,CAAC;IACpE,CAAC;IAED;;OAEG;IACK,sBAAsB,CAC5B,GAAW,EACX,UAAkB;QAElB,oEAAoE;QACpE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,eAAe,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,eAAe,GAAG,CAAC,EAAE,CAAC;YACjE,OAAO,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAEF,CAAA;AA/YY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,+BAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,eAAM,EAAC,gCAAoB,CAAC,CAAA;qCADwB,iBAAK;GALjD,mBAAmB,CA+Y/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index-manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/job-processor/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/job-processor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
|
2
|
-
import { Job } from 'bullmq';
|
|
3
|
-
import { IJobProcessorRegistry, IAtomicJobData, IJobResult, IDynamicExecutor, JobProcessor, Constructor } from '../../domain';
|
|
4
|
-
import { IAtomicQueuesModuleConfig } from '../../domain';
|
|
5
|
-
/**
|
|
6
|
-
* JobProcessorRegistry
|
|
7
|
-
*
|
|
8
|
-
* Registry for job processors that can be looked up by job type.
|
|
9
|
-
* Supports both custom processors and CQRS command/query execution.
|
|
10
|
-
*/
|
|
11
|
-
export declare class JobProcessorRegistry implements IJobProcessorRegistry {
|
|
12
|
-
private readonly logger;
|
|
13
|
-
private readonly processors;
|
|
14
|
-
/**
|
|
15
|
-
* Register a processor for a job type.
|
|
16
|
-
*/
|
|
17
|
-
registerProcessor<T, R>(jobType: string, processor: JobProcessor<T, R>): void;
|
|
18
|
-
/**
|
|
19
|
-
* Get processor for a job type.
|
|
20
|
-
*/
|
|
21
|
-
getProcessor<T, R>(jobType: string): JobProcessor<T, R> | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Check if processor exists.
|
|
24
|
-
*/
|
|
25
|
-
hasProcessor(jobType: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Get all registered job types.
|
|
28
|
-
*/
|
|
29
|
-
getRegisteredTypes(): string[];
|
|
30
|
-
/**
|
|
31
|
-
* Unregister a processor.
|
|
32
|
-
*/
|
|
33
|
-
unregisterProcessor(jobType: string): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Clear all processors.
|
|
36
|
-
*/
|
|
37
|
-
clearAll(): void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* DynamicExecutorService
|
|
41
|
-
*
|
|
42
|
-
* Executes commands and queries dynamically by class name.
|
|
43
|
-
* This is the pattern used by bl-blackjack-service for the ServiceAtomicProcessor.
|
|
44
|
-
*
|
|
45
|
-
* Key Features:
|
|
46
|
-
* - Dynamic module loading for commands/queries
|
|
47
|
-
* - Uses class-transformer to instantiate payloads
|
|
48
|
-
* - Supports both CommandBus and QueryBus execution
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* // Register modules
|
|
53
|
-
* executor.registerCommandModule('../application/commands');
|
|
54
|
-
* executor.registerQueryModule('../application/queries');
|
|
55
|
-
*
|
|
56
|
-
* // Execute dynamically
|
|
57
|
-
* const result = await executor.executeCommand('MakeBetCommand', { amount: 100 });
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare class DynamicExecutorService implements IDynamicExecutor {
|
|
61
|
-
private readonly commandBus;
|
|
62
|
-
private readonly queryBus;
|
|
63
|
-
private readonly logger;
|
|
64
|
-
private readonly commandModules;
|
|
65
|
-
private readonly queryModules;
|
|
66
|
-
private readonly cachedCommandClasses;
|
|
67
|
-
private readonly cachedQueryClasses;
|
|
68
|
-
constructor(commandBus: CommandBus, queryBus: QueryBus);
|
|
69
|
-
/**
|
|
70
|
-
* Execute a command by class name.
|
|
71
|
-
*/
|
|
72
|
-
executeCommand<T>(commandName: string, payload: T): Promise<unknown>;
|
|
73
|
-
/**
|
|
74
|
-
* Execute a query by class name.
|
|
75
|
-
*/
|
|
76
|
-
executeQuery<T>(queryName: string, payload: T): Promise<unknown>;
|
|
77
|
-
/**
|
|
78
|
-
* Register command module for dynamic loading.
|
|
79
|
-
*/
|
|
80
|
-
registerCommandModule(modulePath: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Register query module for dynamic loading.
|
|
83
|
-
*/
|
|
84
|
-
registerQueryModule(modulePath: string): void;
|
|
85
|
-
/**
|
|
86
|
-
* Pre-register a command class directly (preferred method).
|
|
87
|
-
*/
|
|
88
|
-
registerCommandClass(name: string, commandClass: Constructor): void;
|
|
89
|
-
/**
|
|
90
|
-
* Pre-register a query class directly (preferred method).
|
|
91
|
-
*/
|
|
92
|
-
registerQueryClass(name: string, queryClass: Constructor): void;
|
|
93
|
-
/**
|
|
94
|
-
* Bulk register command classes.
|
|
95
|
-
*/
|
|
96
|
-
registerCommandClasses(classes: Record<string, Constructor>): void;
|
|
97
|
-
/**
|
|
98
|
-
* Bulk register query classes.
|
|
99
|
-
*/
|
|
100
|
-
registerQueryClasses(classes: Record<string, Constructor>): void;
|
|
101
|
-
/**
|
|
102
|
-
* Resolve a command class by name.
|
|
103
|
-
*/
|
|
104
|
-
private resolveCommandClass;
|
|
105
|
-
/**
|
|
106
|
-
* Resolve a query class by name.
|
|
107
|
-
*/
|
|
108
|
-
private resolveQueryClass;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* AtomicJobProcessor
|
|
112
|
-
*
|
|
113
|
-
* Main job processor service that combines the registry and dynamic executor
|
|
114
|
-
* to process atomic jobs with support for:
|
|
115
|
-
*
|
|
116
|
-
* 1. Custom registered processors
|
|
117
|
-
* 2. Dynamic CQRS command/query execution
|
|
118
|
-
* 3. Job progress tracking
|
|
119
|
-
* 4. Error handling and result capture
|
|
120
|
-
*
|
|
121
|
-
* This is the unified processor that should be used by workers.
|
|
122
|
-
*/
|
|
123
|
-
export declare class AtomicJobProcessor {
|
|
124
|
-
private readonly registry;
|
|
125
|
-
private readonly executor;
|
|
126
|
-
private readonly config;
|
|
127
|
-
private readonly logger;
|
|
128
|
-
constructor(registry: JobProcessorRegistry, executor: DynamicExecutorService, config: IAtomicQueuesModuleConfig);
|
|
129
|
-
/**
|
|
130
|
-
* Process an atomic job.
|
|
131
|
-
*
|
|
132
|
-
* Processing order:
|
|
133
|
-
* 1. Check for custom registered processor
|
|
134
|
-
* 2. If type is 'command', use dynamic executor
|
|
135
|
-
* 3. If type is 'query', use dynamic executor
|
|
136
|
-
* 4. If type is 'custom', use registered processor only
|
|
137
|
-
*/
|
|
138
|
-
process<T = unknown, R = unknown>(job: Job<IAtomicJobData<T>>): Promise<IJobResult<R>>;
|
|
139
|
-
/**
|
|
140
|
-
* Create a processor function for use with WorkerManager.createWorker().
|
|
141
|
-
*/
|
|
142
|
-
createProcessor<T = unknown, R = unknown>(): (job: Job<IAtomicJobData<T>>) => Promise<R | undefined>;
|
|
143
|
-
/**
|
|
144
|
-
* Register a custom processor.
|
|
145
|
-
*/
|
|
146
|
-
registerProcessor<T, R>(jobType: string, processor: JobProcessor<T, R>): void;
|
|
147
|
-
/**
|
|
148
|
-
* Register command classes for dynamic execution.
|
|
149
|
-
*/
|
|
150
|
-
registerCommands(classes: Record<string, Constructor>): void;
|
|
151
|
-
/**
|
|
152
|
-
* Register query classes for dynamic execution.
|
|
153
|
-
*/
|
|
154
|
-
registerQueries(classes: Record<string, Constructor>): void;
|
|
155
|
-
}
|
|
156
|
-
//# sourceMappingURL=job-processor.service.d.ts.map
|