atomic-queues 1.6.2 → 2.0.1

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.
Files changed (337) hide show
  1. package/README.md +273 -413
  2. package/dist/cli/generators/json-schema.d.ts +3 -0
  3. package/dist/cli/generators/json-schema.d.ts.map +1 -0
  4. package/dist/cli/generators/json-schema.js +31 -0
  5. package/dist/cli/generators/json-schema.js.map +1 -0
  6. package/dist/cli/generators/typescript.d.ts +3 -0
  7. package/dist/cli/generators/typescript.d.ts.map +1 -0
  8. package/dist/cli/generators/typescript.js +62 -0
  9. package/dist/cli/generators/typescript.js.map +1 -0
  10. package/dist/cli/index.d.ts +3 -0
  11. package/dist/cli/index.d.ts.map +1 -0
  12. package/dist/cli/index.js +156 -0
  13. package/dist/cli/index.js.map +1 -0
  14. package/dist/decorators/actor.decorators.d.ts +4 -0
  15. package/dist/decorators/actor.decorators.d.ts.map +1 -0
  16. package/dist/decorators/actor.decorators.js +32 -0
  17. package/dist/decorators/actor.decorators.js.map +1 -0
  18. package/dist/decorators/constants.d.ts +5 -12
  19. package/dist/decorators/constants.d.ts.map +1 -1
  20. package/dist/decorators/constants.js +10 -16
  21. package/dist/decorators/constants.js.map +1 -1
  22. package/dist/decorators/index.d.ts +4 -4
  23. package/dist/decorators/index.d.ts.map +1 -1
  24. package/dist/decorators/index.js +4 -4
  25. package/dist/decorators/index.js.map +1 -1
  26. package/dist/decorators/interfaces.d.ts +18 -78
  27. package/dist/decorators/interfaces.d.ts.map +1 -1
  28. package/dist/decorators/metadata-readers.d.ts +5 -26
  29. package/dist/decorators/metadata-readers.d.ts.map +1 -1
  30. package/dist/decorators/metadata-readers.js +16 -33
  31. package/dist/decorators/metadata-readers.js.map +1 -1
  32. package/dist/decorators/schema.decorators.d.ts +2 -0
  33. package/dist/decorators/schema.decorators.d.ts.map +1 -0
  34. package/dist/decorators/schema.decorators.js +13 -0
  35. package/dist/decorators/schema.decorators.js.map +1 -0
  36. package/dist/domain/interfaces/config.interfaces.d.ts +52 -153
  37. package/dist/domain/interfaces/config.interfaces.d.ts.map +1 -1
  38. package/dist/domain/interfaces/index.d.ts +0 -7
  39. package/dist/domain/interfaces/index.d.ts.map +1 -1
  40. package/dist/domain/interfaces/index.js +0 -7
  41. package/dist/domain/interfaces/index.js.map +1 -1
  42. package/dist/domain/interfaces/job.interfaces.d.ts +32 -65
  43. package/dist/domain/interfaces/job.interfaces.d.ts.map +1 -1
  44. package/dist/index.d.ts +0 -34
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +0 -39
  47. package/dist/index.js.map +1 -1
  48. package/dist/module/atomic-queues.module.d.ts +0 -83
  49. package/dist/module/atomic-queues.module.d.ts.map +1 -1
  50. package/dist/module/atomic-queues.module.js +35 -134
  51. package/dist/module/atomic-queues.module.js.map +1 -1
  52. package/dist/services/actor-registry/actor-registry.service.d.ts +30 -0
  53. package/dist/services/actor-registry/actor-registry.service.d.ts.map +1 -0
  54. package/dist/services/actor-registry/actor-registry.service.js +186 -0
  55. package/dist/services/actor-registry/actor-registry.service.js.map +1 -0
  56. package/dist/services/actor-registry/index.d.ts +2 -0
  57. package/dist/services/actor-registry/index.d.ts.map +1 -0
  58. package/dist/services/actor-registry/index.js +18 -0
  59. package/dist/services/actor-registry/index.js.map +1 -0
  60. package/dist/services/actor-system/actor-system.service.d.ts +19 -0
  61. package/dist/services/actor-system/actor-system.service.d.ts.map +1 -0
  62. package/dist/services/actor-system/actor-system.service.js +86 -0
  63. package/dist/services/actor-system/actor-system.service.js.map +1 -0
  64. package/dist/services/actor-system/index.d.ts +2 -0
  65. package/dist/services/actor-system/index.d.ts.map +1 -0
  66. package/dist/services/{cron-manager → actor-system}/index.js +1 -1
  67. package/dist/services/actor-system/index.js.map +1 -0
  68. package/dist/services/command-discovery/command-discovery.service.d.ts +6 -53
  69. package/dist/services/command-discovery/command-discovery.service.d.ts.map +1 -1
  70. package/dist/services/command-discovery/command-discovery.service.js +0 -59
  71. package/dist/services/command-discovery/command-discovery.service.js.map +1 -1
  72. package/dist/services/constants.d.ts +2 -9
  73. package/dist/services/constants.d.ts.map +1 -1
  74. package/dist/services/constants.js +3 -10
  75. package/dist/services/constants.js.map +1 -1
  76. package/dist/services/executor-pool/executor-pool.service.d.ts +31 -0
  77. package/dist/services/executor-pool/executor-pool.service.d.ts.map +1 -0
  78. package/dist/services/executor-pool/executor-pool.service.js +147 -0
  79. package/dist/services/executor-pool/executor-pool.service.js.map +1 -0
  80. package/dist/services/executor-pool/index.d.ts +2 -0
  81. package/dist/services/executor-pool/index.d.ts.map +1 -0
  82. package/dist/services/{queue-manager → executor-pool}/index.js +1 -1
  83. package/dist/services/executor-pool/index.js.map +1 -0
  84. package/dist/services/gate/gate.service.d.ts +17 -0
  85. package/dist/services/gate/gate.service.d.ts.map +1 -0
  86. package/dist/services/gate/gate.service.js +66 -0
  87. package/dist/services/gate/gate.service.js.map +1 -0
  88. package/dist/services/gate/index.d.ts +2 -0
  89. package/dist/services/gate/index.d.ts.map +1 -0
  90. package/dist/services/{spawn-queue → gate}/index.js +1 -1
  91. package/dist/services/gate/index.js.map +1 -0
  92. package/dist/services/handler-executor/handler-executor.service.d.ts +32 -0
  93. package/dist/services/handler-executor/handler-executor.service.d.ts.map +1 -0
  94. package/dist/services/handler-executor/handler-executor.service.js +186 -0
  95. package/dist/services/handler-executor/handler-executor.service.js.map +1 -0
  96. package/dist/services/handler-executor/index.d.ts +2 -0
  97. package/dist/services/handler-executor/index.d.ts.map +1 -0
  98. package/dist/services/handler-executor/index.js +18 -0
  99. package/dist/services/handler-executor/index.js.map +1 -0
  100. package/dist/services/index.d.ts +11 -12
  101. package/dist/services/index.d.ts.map +1 -1
  102. package/dist/services/index.js +11 -12
  103. package/dist/services/index.js.map +1 -1
  104. package/dist/services/log/index.d.ts +2 -0
  105. package/dist/services/log/index.d.ts.map +1 -0
  106. package/dist/services/{index-manager → log}/index.js +1 -1
  107. package/dist/services/log/index.js.map +1 -0
  108. package/dist/services/log/log.service.d.ts +21 -0
  109. package/dist/services/log/log.service.d.ts.map +1 -0
  110. package/dist/services/log/log.service.js +92 -0
  111. package/dist/services/log/log.service.js.map +1 -0
  112. package/dist/services/queue-bus/index.d.ts +0 -4
  113. package/dist/services/queue-bus/index.d.ts.map +1 -1
  114. package/dist/services/queue-bus/index.js +0 -4
  115. package/dist/services/queue-bus/index.js.map +1 -1
  116. package/dist/services/queue-bus/queue-bus.service.d.ts +44 -198
  117. package/dist/services/queue-bus/queue-bus.service.d.ts.map +1 -1
  118. package/dist/services/queue-bus/queue-bus.service.js +103 -259
  119. package/dist/services/queue-bus/queue-bus.service.js.map +1 -1
  120. package/dist/services/queue-bus/queue-bus.utils.d.ts +0 -28
  121. package/dist/services/queue-bus/queue-bus.utils.d.ts.map +1 -1
  122. package/dist/services/queue-bus/queue-bus.utils.js +1 -41
  123. package/dist/services/queue-bus/queue-bus.utils.js.map +1 -1
  124. package/dist/services/registry/index.d.ts +4 -0
  125. package/dist/services/registry/index.d.ts.map +1 -0
  126. package/dist/services/{queue-events-manager → registry}/index.js +3 -1
  127. package/dist/services/registry/index.js.map +1 -0
  128. package/dist/services/registry/registry.service.d.ts +43 -0
  129. package/dist/services/registry/registry.service.d.ts.map +1 -0
  130. package/dist/services/registry/registry.service.js +379 -0
  131. package/dist/services/registry/registry.service.js.map +1 -0
  132. package/dist/services/registry/registry.types.d.ts +24 -0
  133. package/dist/services/registry/registry.types.d.ts.map +1 -0
  134. package/dist/{domain/interfaces/lock.interfaces.js → services/registry/registry.types.js} +1 -1
  135. package/dist/services/registry/registry.types.js.map +1 -0
  136. package/dist/services/registry/schema-converter.d.ts +2 -0
  137. package/dist/services/registry/schema-converter.d.ts.map +1 -0
  138. package/dist/services/registry/schema-converter.js +27 -0
  139. package/dist/services/registry/schema-converter.js.map +1 -0
  140. package/dist/services/result-collector/index.d.ts +2 -0
  141. package/dist/services/result-collector/index.d.ts.map +1 -0
  142. package/dist/services/result-collector/index.js +18 -0
  143. package/dist/services/result-collector/index.js.map +1 -0
  144. package/dist/services/result-collector/result-collector.service.d.ts +17 -0
  145. package/dist/services/result-collector/result-collector.service.d.ts.map +1 -0
  146. package/dist/services/result-collector/result-collector.service.js +92 -0
  147. package/dist/services/result-collector/result-collector.service.js.map +1 -0
  148. package/dist/services/scheduler/index.d.ts +2 -0
  149. package/dist/services/scheduler/index.d.ts.map +1 -0
  150. package/dist/services/{job-processor → scheduler}/index.js +1 -1
  151. package/dist/services/scheduler/index.js.map +1 -0
  152. package/dist/services/scheduler/scheduler.service.d.ts +17 -0
  153. package/dist/services/scheduler/scheduler.service.d.ts.map +1 -0
  154. package/dist/services/scheduler/scheduler.service.js +116 -0
  155. package/dist/services/scheduler/scheduler.service.js.map +1 -0
  156. package/dist/services/shutdown/index.d.ts +2 -0
  157. package/dist/services/shutdown/index.d.ts.map +1 -0
  158. package/dist/services/shutdown/index.js +18 -0
  159. package/dist/services/shutdown/index.js.map +1 -0
  160. package/dist/services/shutdown/shutdown.service.d.ts +8 -0
  161. package/dist/services/shutdown/shutdown.service.d.ts.map +1 -0
  162. package/dist/services/shutdown/shutdown.service.js +29 -0
  163. package/dist/services/shutdown/shutdown.service.js.map +1 -0
  164. package/dist/utils/index.d.ts +3 -1
  165. package/dist/utils/index.d.ts.map +1 -1
  166. package/dist/utils/index.js +3 -1
  167. package/dist/utils/index.js.map +1 -1
  168. package/dist/utils/naming.utils.d.ts +0 -16
  169. package/dist/utils/naming.utils.d.ts.map +1 -1
  170. package/dist/utils/naming.utils.js +0 -29
  171. package/dist/utils/naming.utils.js.map +1 -1
  172. package/package.json +19 -11
  173. package/dist/decorators/legacy.decorators.d.ts +0 -36
  174. package/dist/decorators/legacy.decorators.d.ts.map +0 -1
  175. package/dist/decorators/legacy.decorators.js +0 -61
  176. package/dist/decorators/legacy.decorators.js.map +0 -1
  177. package/dist/decorators/scaler.decorators.d.ts +0 -65
  178. package/dist/decorators/scaler.decorators.d.ts.map +0 -1
  179. package/dist/decorators/scaler.decorators.js +0 -103
  180. package/dist/decorators/scaler.decorators.js.map +0 -1
  181. package/dist/decorators/type-guards.d.ts +0 -18
  182. package/dist/decorators/type-guards.d.ts.map +0 -1
  183. package/dist/decorators/type-guards.js +0 -32
  184. package/dist/decorators/type-guards.js.map +0 -1
  185. package/dist/decorators/worker.decorators.d.ts +0 -58
  186. package/dist/decorators/worker.decorators.d.ts.map +0 -1
  187. package/dist/decorators/worker.decorators.js +0 -92
  188. package/dist/decorators/worker.decorators.js.map +0 -1
  189. package/dist/domain/interfaces/event.interfaces.d.ts +0 -71
  190. package/dist/domain/interfaces/event.interfaces.d.ts.map +0 -1
  191. package/dist/domain/interfaces/event.interfaces.js +0 -3
  192. package/dist/domain/interfaces/event.interfaces.js.map +0 -1
  193. package/dist/domain/interfaces/index-tracking.interfaces.d.ts +0 -69
  194. package/dist/domain/interfaces/index-tracking.interfaces.d.ts.map +0 -1
  195. package/dist/domain/interfaces/index-tracking.interfaces.js +0 -3
  196. package/dist/domain/interfaces/index-tracking.interfaces.js.map +0 -1
  197. package/dist/domain/interfaces/lock.interfaces.d.ts +0 -54
  198. package/dist/domain/interfaces/lock.interfaces.d.ts.map +0 -1
  199. package/dist/domain/interfaces/lock.interfaces.js.map +0 -1
  200. package/dist/domain/interfaces/process.interfaces.d.ts +0 -44
  201. package/dist/domain/interfaces/process.interfaces.d.ts.map +0 -1
  202. package/dist/domain/interfaces/process.interfaces.js +0 -3
  203. package/dist/domain/interfaces/process.interfaces.js.map +0 -1
  204. package/dist/domain/interfaces/queue.interfaces.d.ts +0 -46
  205. package/dist/domain/interfaces/queue.interfaces.d.ts.map +0 -1
  206. package/dist/domain/interfaces/queue.interfaces.js +0 -3
  207. package/dist/domain/interfaces/queue.interfaces.js.map +0 -1
  208. package/dist/domain/interfaces/scaling.interfaces.d.ts +0 -62
  209. package/dist/domain/interfaces/scaling.interfaces.d.ts.map +0 -1
  210. package/dist/domain/interfaces/scaling.interfaces.js +0 -3
  211. package/dist/domain/interfaces/scaling.interfaces.js.map +0 -1
  212. package/dist/domain/interfaces/worker.interfaces.d.ts +0 -120
  213. package/dist/domain/interfaces/worker.interfaces.d.ts.map +0 -1
  214. package/dist/domain/interfaces/worker.interfaces.js +0 -3
  215. package/dist/domain/interfaces/worker.interfaces.js.map +0 -1
  216. package/dist/services/cron-manager/cron-manager.service.d.ts +0 -199
  217. package/dist/services/cron-manager/cron-manager.service.d.ts.map +0 -1
  218. package/dist/services/cron-manager/cron-manager.service.js +0 -583
  219. package/dist/services/cron-manager/cron-manager.service.js.map +0 -1
  220. package/dist/services/cron-manager/index.d.ts +0 -2
  221. package/dist/services/cron-manager/index.d.ts.map +0 -1
  222. package/dist/services/cron-manager/index.js.map +0 -1
  223. package/dist/services/index-manager/index-manager.service.d.ts +0 -142
  224. package/dist/services/index-manager/index-manager.service.d.ts.map +0 -1
  225. package/dist/services/index-manager/index-manager.service.js +0 -325
  226. package/dist/services/index-manager/index-manager.service.js.map +0 -1
  227. package/dist/services/index-manager/index.d.ts +0 -2
  228. package/dist/services/index-manager/index.d.ts.map +0 -1
  229. package/dist/services/index-manager/index.js.map +0 -1
  230. package/dist/services/job-processor/index.d.ts +0 -2
  231. package/dist/services/job-processor/index.d.ts.map +0 -1
  232. package/dist/services/job-processor/index.js.map +0 -1
  233. package/dist/services/job-processor/job-processor.service.d.ts +0 -156
  234. package/dist/services/job-processor/job-processor.service.d.ts.map +0 -1
  235. package/dist/services/job-processor/job-processor.service.js +0 -331
  236. package/dist/services/job-processor/job-processor.service.js.map +0 -1
  237. package/dist/services/processor-discovery/decorator-discovery.service.d.ts +0 -40
  238. package/dist/services/processor-discovery/decorator-discovery.service.d.ts.map +0 -1
  239. package/dist/services/processor-discovery/decorator-discovery.service.js +0 -191
  240. package/dist/services/processor-discovery/decorator-discovery.service.js.map +0 -1
  241. package/dist/services/processor-discovery/index.d.ts +0 -6
  242. package/dist/services/processor-discovery/index.d.ts.map +0 -1
  243. package/dist/services/processor-discovery/index.js +0 -22
  244. package/dist/services/processor-discovery/index.js.map +0 -1
  245. package/dist/services/processor-discovery/processor-discovery.service.d.ts +0 -98
  246. package/dist/services/processor-discovery/processor-discovery.service.d.ts.map +0 -1
  247. package/dist/services/processor-discovery/processor-discovery.service.js +0 -258
  248. package/dist/services/processor-discovery/processor-discovery.service.js.map +0 -1
  249. package/dist/services/processor-discovery/processor-registry.d.ts +0 -58
  250. package/dist/services/processor-discovery/processor-registry.d.ts.map +0 -1
  251. package/dist/services/processor-discovery/processor-registry.js +0 -74
  252. package/dist/services/processor-discovery/processor-registry.js.map +0 -1
  253. package/dist/services/processor-discovery/scaling-registration.service.d.ts +0 -60
  254. package/dist/services/processor-discovery/scaling-registration.service.d.ts.map +0 -1
  255. package/dist/services/processor-discovery/scaling-registration.service.js +0 -261
  256. package/dist/services/processor-discovery/scaling-registration.service.js.map +0 -1
  257. package/dist/services/processor-discovery/worker-factory.service.d.ts +0 -54
  258. package/dist/services/processor-discovery/worker-factory.service.d.ts.map +0 -1
  259. package/dist/services/processor-discovery/worker-factory.service.js +0 -185
  260. package/dist/services/processor-discovery/worker-factory.service.js.map +0 -1
  261. package/dist/services/queue-bus/entity-target.d.ts +0 -58
  262. package/dist/services/queue-bus/entity-target.d.ts.map +0 -1
  263. package/dist/services/queue-bus/entity-target.js +0 -109
  264. package/dist/services/queue-bus/entity-target.js.map +0 -1
  265. package/dist/services/queue-bus/queue-bus.types.d.ts +0 -40
  266. package/dist/services/queue-bus/queue-bus.types.d.ts.map +0 -1
  267. package/dist/services/queue-bus/queue-bus.types.js +0 -3
  268. package/dist/services/queue-bus/queue-bus.types.js.map +0 -1
  269. package/dist/services/queue-bus/queue-target.d.ts +0 -61
  270. package/dist/services/queue-bus/queue-target.d.ts.map +0 -1
  271. package/dist/services/queue-bus/queue-target.js +0 -123
  272. package/dist/services/queue-bus/queue-target.js.map +0 -1
  273. package/dist/services/queue-events-manager/index.d.ts +0 -2
  274. package/dist/services/queue-events-manager/index.d.ts.map +0 -1
  275. package/dist/services/queue-events-manager/index.js.map +0 -1
  276. package/dist/services/queue-events-manager/queue-events-manager.service.d.ts +0 -120
  277. package/dist/services/queue-events-manager/queue-events-manager.service.d.ts.map +0 -1
  278. package/dist/services/queue-events-manager/queue-events-manager.service.js +0 -343
  279. package/dist/services/queue-events-manager/queue-events-manager.service.js.map +0 -1
  280. package/dist/services/queue-manager/index.d.ts +0 -2
  281. package/dist/services/queue-manager/index.d.ts.map +0 -1
  282. package/dist/services/queue-manager/index.js.map +0 -1
  283. package/dist/services/queue-manager/queue-manager.service.d.ts +0 -148
  284. package/dist/services/queue-manager/queue-manager.service.d.ts.map +0 -1
  285. package/dist/services/queue-manager/queue-manager.service.js +0 -348
  286. package/dist/services/queue-manager/queue-manager.service.js.map +0 -1
  287. package/dist/services/resource-lock/index.d.ts +0 -2
  288. package/dist/services/resource-lock/index.d.ts.map +0 -1
  289. package/dist/services/resource-lock/index.js +0 -18
  290. package/dist/services/resource-lock/index.js.map +0 -1
  291. package/dist/services/resource-lock/resource-lock.service.d.ts +0 -120
  292. package/dist/services/resource-lock/resource-lock.service.d.ts.map +0 -1
  293. package/dist/services/resource-lock/resource-lock.service.js +0 -367
  294. package/dist/services/resource-lock/resource-lock.service.js.map +0 -1
  295. package/dist/services/service-queue/index.d.ts +0 -3
  296. package/dist/services/service-queue/index.d.ts.map +0 -1
  297. package/dist/services/service-queue/index.js +0 -19
  298. package/dist/services/service-queue/index.js.map +0 -1
  299. package/dist/services/service-queue/service-queue.service.d.ts +0 -199
  300. package/dist/services/service-queue/service-queue.service.d.ts.map +0 -1
  301. package/dist/services/service-queue/service-queue.service.js +0 -617
  302. package/dist/services/service-queue/service-queue.service.js.map +0 -1
  303. package/dist/services/service-queue/service-queue.types.d.ts +0 -32
  304. package/dist/services/service-queue/service-queue.types.d.ts.map +0 -1
  305. package/dist/services/service-queue/service-queue.types.js +0 -27
  306. package/dist/services/service-queue/service-queue.types.js.map +0 -1
  307. package/dist/services/shutdown-state/index.d.ts +0 -2
  308. package/dist/services/shutdown-state/index.d.ts.map +0 -1
  309. package/dist/services/shutdown-state/index.js +0 -18
  310. package/dist/services/shutdown-state/index.js.map +0 -1
  311. package/dist/services/shutdown-state/shutdown-state.service.d.ts +0 -69
  312. package/dist/services/shutdown-state/shutdown-state.service.d.ts.map +0 -1
  313. package/dist/services/shutdown-state/shutdown-state.service.js +0 -127
  314. package/dist/services/shutdown-state/shutdown-state.service.js.map +0 -1
  315. package/dist/services/spawn-queue/index.d.ts +0 -2
  316. package/dist/services/spawn-queue/index.d.ts.map +0 -1
  317. package/dist/services/spawn-queue/index.js.map +0 -1
  318. package/dist/services/spawn-queue/spawn-queue.service.d.ts +0 -119
  319. package/dist/services/spawn-queue/spawn-queue.service.d.ts.map +0 -1
  320. package/dist/services/spawn-queue/spawn-queue.service.js +0 -273
  321. package/dist/services/spawn-queue/spawn-queue.service.js.map +0 -1
  322. package/dist/services/worker-manager/index.d.ts +0 -2
  323. package/dist/services/worker-manager/index.d.ts.map +0 -1
  324. package/dist/services/worker-manager/index.js +0 -18
  325. package/dist/services/worker-manager/index.js.map +0 -1
  326. package/dist/services/worker-manager/worker-manager.service.d.ts +0 -221
  327. package/dist/services/worker-manager/worker-manager.service.d.ts.map +0 -1
  328. package/dist/services/worker-manager/worker-manager.service.js +0 -591
  329. package/dist/services/worker-manager/worker-manager.service.js.map +0 -1
  330. package/dist/utils/helpers.d.ts +0 -5
  331. package/dist/utils/helpers.d.ts.map +0 -1
  332. package/dist/utils/helpers.js +0 -21
  333. package/dist/utils/helpers.js.map +0 -1
  334. package/dist/utils/job.utils.d.ts +0 -50
  335. package/dist/utils/job.utils.d.ts.map +0 -1
  336. package/dist/utils/job.utils.js +0 -89
  337. package/dist/utils/job.utils.js.map +0 -1
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityTarget = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const queue_bus_utils_1 = require("./queue-bus.utils");
6
- /**
7
- * EntityTarget - Fluent builder for targeting a specific entity type's queue
8
- * without needing a @WorkerProcessor class.
9
- *
10
- * This is the zero-boilerplate way to enqueue commands when you've configured
11
- * entity defaults in the module config.
12
- *
13
- * @example
14
- * await queueBus
15
- * .forEntity('table')
16
- * .enqueue(new MakeBetCommand(tableId, bets, player));
17
- */
18
- class EntityTarget {
19
- constructor(queueManager, entityType, entityConfig, keyPrefix, queueEventsManager) {
20
- this.queueManager = queueManager;
21
- this.entityType = entityType;
22
- this.entityConfig = entityConfig;
23
- this.keyPrefix = keyPrefix;
24
- this.queueEventsManager = queueEventsManager;
25
- this.logger = new common_1.Logger(EntityTarget.name);
26
- }
27
- /**
28
- * Get the queue name function from entity config or defaults
29
- */
30
- getQueueNameFn() {
31
- if (this.entityConfig?.queueName) {
32
- return this.entityConfig.queueName;
33
- }
34
- // Default: {keyPrefix}-{entityType}-{entityId}-queue
35
- return (entityId) => `${this.keyPrefix}-${this.entityType}-${entityId}-queue`;
36
- }
37
- /**
38
- * Extract entity ID using the priority chain (no processor-level default)
39
- */
40
- extractEntityId(commandOrQuery, data) {
41
- return (0, queue_bus_utils_1.extractEntityIdExplicit)(commandOrQuery, data, undefined, // No processor default for forEntity()
42
- this.entityConfig, this.logger);
43
- }
44
- /**
45
- * Enqueue a command/query for processing
46
- *
47
- * @param commandOrQuery - The command or query instance
48
- * @param options - Optional settings (entityId override, jobOptions)
49
- * @returns The created BullMQ job
50
- *
51
- * @example
52
- * await queueBus
53
- * .forEntity('table')
54
- * .enqueue(new MakeBetCommand(tableId, bets, player));
55
- */
56
- async enqueue(commandOrQuery, options) {
57
- const jobName = (0, queue_bus_utils_1.getJobName)(commandOrQuery);
58
- const data = (0, queue_bus_utils_1.extractData)(commandOrQuery);
59
- const entityId = options?.entityId ?? this.extractEntityId(commandOrQuery, data);
60
- const queueNameFn = this.getQueueNameFn();
61
- const queueName = queueNameFn(entityId);
62
- this.logger.debug(`[forEntity:${this.entityType}] Adding job ${jobName} to queue ${queueName}`);
63
- // Get queue and ensure event listening
64
- const queue = this.queueManager.getOrCreateQueue(queueName);
65
- if (this.queueEventsManager) {
66
- await this.queueEventsManager.ensureListening(queueName, this.entityType);
67
- }
68
- // Add job to queue
69
- return queue.add(jobName, data, options?.jobOptions);
70
- }
71
- /**
72
- * Enqueue and wait for result
73
- */
74
- async enqueueAndWait(commandOrQuery, options) {
75
- const job = await this.enqueue(commandOrQuery, options);
76
- const data = (0, queue_bus_utils_1.extractData)(commandOrQuery);
77
- const entityId = options?.entityId ?? this.extractEntityId(commandOrQuery, data);
78
- const queueNameFn = this.getQueueNameFn();
79
- const queueName = queueNameFn(entityId);
80
- const queueEvents = await this.queueManager.getQueueEvents(queueName);
81
- return job.waitUntilFinished(queueEvents, options?.timeout);
82
- }
83
- /**
84
- * Enqueue multiple commands/queries in bulk
85
- */
86
- async enqueueBulk(commandsOrQueries, options) {
87
- if (commandsOrQueries.length === 0)
88
- return [];
89
- const firstCmd = commandsOrQueries[0];
90
- const firstData = (0, queue_bus_utils_1.extractData)(firstCmd);
91
- const entityId = options?.entityId ?? this.extractEntityId(firstCmd, firstData);
92
- const queueNameFn = this.getQueueNameFn();
93
- const queueName = queueNameFn(entityId);
94
- const queue = this.queueManager.getOrCreateQueue(queueName);
95
- // Ensure listening is set up for auto-spawn
96
- if (this.queueEventsManager) {
97
- await this.queueEventsManager.ensureListening(queueName, this.entityType);
98
- }
99
- const bulkJobs = commandsOrQueries.map((cmd) => ({
100
- name: (0, queue_bus_utils_1.getJobName)(cmd),
101
- data: (0, queue_bus_utils_1.extractData)(cmd),
102
- opts: options?.jobOptions,
103
- }));
104
- this.logger.debug(`[forEntity:${this.entityType}] Adding ${bulkJobs.length} jobs to queue ${queueName}`);
105
- return queue.addBulk(bulkJobs);
106
- }
107
- }
108
- exports.EntityTarget = EntityTarget;
109
- //# sourceMappingURL=entity-target.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entity-target.js","sourceRoot":"","sources":["../../../src/services/queue-bus/entity-target.ts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ue(command) instead
6
- */
7
- export interface QueueBusExecuteOptions {
8
- /**
9
- * The entity ID to use for queue name resolution.
10
- * If not provided, will try to extract from command properties:
11
- * entityId, tableId, userId, id (in that order)
12
- */
13
- entityId?: string;
14
- /**
15
- * BullMQ job options (priority, delay, attempts, etc.)
16
- */
17
- jobOptions?: JobsOptions;
18
- }
19
- /**
20
- * Options for .enqueue()
21
- */
22
- export interface EnqueueOptions {
23
- /**
24
- * Override the auto-extracted entityId
25
- */
26
- entityId?: string;
27
- /**
28
- * BullMQ job options (priority, delay, attempts, etc.)
29
- */
30
- jobOptions?: JobsOptions;
31
- }
32
- /**
33
- * Registry entry for a command/query class
34
- */
35
- export interface CommandRegistryEntry {
36
- className: string;
37
- targetClass: Type<any>;
38
- isQuery: boolean;
39
- }
40
- //# sourceMappingURL=queue-bus.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue-bus.types.d.ts","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-bus.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=queue-bus.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue-bus.types.js","sourceRoot":"","sources":["../../../src/services/queue-bus/queue-bus.types.ts"],"names":[],"mappings":""}
@@ -1,61 +0,0 @@
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
@@ -1 +0,0 @@
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,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,sDAAsD,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;;;;GAOG;AACH,qBAAa,WAAW;IAIpB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAPtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;gBAGpC,YAAY,EAAE,mBAAmB,EACjC,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,EACzB,gBAAgB,EAAE,sBAAsB,EACxC,YAAY,CAAC,EAAE,aAAa,YAAA,EAC5B,kBAAkB,CAAC,EAAE,yBAAyB,YAAA;IAGjE;;OAEG;IACH,OAAO,CAAC,cAAc;IAsBtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;;;;;;;;;;;;;;;OAgBG;IACG,OAAO,CAAC,CAAC,SAAS,MAAM,EAC5B,cAAc,EAAE,CAAC,EACjB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC;IA0Bf;;OAEG;IACG,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,GAAG,EAC5C,cAAc,EAAE,CAAC,EACjB,OAAO,CAAC,EAAE,cAAc,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9C,OAAO,CAAC,CAAC,CAAC;IAab;;OAEG;IACG,WAAW,CAAC,CAAC,SAAS,MAAM,EAChC,iBAAiB,EAAE,CAAC,EAAE,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,EAAE,CAAC;CA6BlB"}
@@ -1,123 +0,0 @@
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
@@ -1 +0,0 @@
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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C,MAAM,kBAAkB,SAAS,EAAE,CACrF,CAAC;QAEF,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACF;AArJD,kCAqJC"}
@@ -1,2 +0,0 @@
1
- export * from './queue-events-manager.service';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/queue-events-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/queue-events-manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C"}
@@ -1,120 +0,0 @@
1
- import { OnModuleDestroy } from '@nestjs/common';
2
- import Redis from 'ioredis';
3
- import { IAtomicQueuesModuleConfig } from '../../domain';
4
- import { WorkerManagerService } from '../worker-manager';
5
- import { ServiceQueueManager } from '../service-queue';
6
- import { SpawnQueueService } from '../spawn-queue';
7
- /**
8
- * Callback for spawning a worker for an entity.
9
- */
10
- export type OnJobArrivedCallback = (entityType: string, entityId: string, queueName: string) => Promise<void>;
11
- /**
12
- * QueueEventsManagerService
13
- *
14
- * Listens to BullMQ queue events using Redis pub/sub (ecological).
15
- * When a job is added to a queue and no worker exists, triggers worker spawning.
16
- *
17
- * This enables a "scalerless" architecture where:
18
- * - Workers are spawned on-demand when jobs arrive
19
- * - Workers terminate themselves when idle
20
- * - No need for @EntityScaler with @GetActiveEntities
21
- *
22
- * Key Features:
23
- * - Redis pub/sub based (ecological) - no polling
24
- * - Uses BullMQ's QueueEvents for reliable event delivery
25
- * - Checks for existing workers before spawning
26
- * - Integrates with ServiceQueue for distributed coordination
27
- *
28
- * @example
29
- * ```typescript
30
- * // Register a queue for event listening
31
- * queueEventsManager.registerQueue({
32
- * queueName: 'aq:table:123:queue',
33
- * entityType: 'table',
34
- * extractEntityId: (qn) => qn.split(':')[2], // 123
35
- * onJobArrived: async (entityType, entityId) => {
36
- * await createWorkerForEntity(entityType, entityId);
37
- * },
38
- * });
39
- * ```
40
- */
41
- export declare class QueueEventsManagerService implements OnModuleDestroy {
42
- private readonly redis;
43
- private readonly config;
44
- private readonly workerManager;
45
- private readonly spawnQueueService?;
46
- private readonly serviceQueueManager?;
47
- private readonly logger;
48
- private readonly registeredQueues;
49
- private readonly keyPrefix;
50
- private readonly useServiceQueue;
51
- private readonly entityPatterns;
52
- private onJobArrivedCallback;
53
- private readonly hotCache;
54
- constructor(redis: Redis, config: IAtomicQueuesModuleConfig, workerManager: WorkerManagerService, spawnQueueService?: SpawnQueueService | undefined, serviceQueueManager?: ServiceQueueManager | undefined);
55
- /**
56
- * Register a callback to be called when a job arrives for any queue
57
- * and no worker exists. Used by ProcessorDiscoveryService.
58
- */
59
- setOnJobArrivedCallback(callback: OnJobArrivedCallback): void;
60
- /**
61
- * Register an entity type pattern for automatic queue event listening.
62
- * When a job is added to any queue matching this pattern, a worker spawn is triggered.
63
- */
64
- registerEntityPattern(entityType: string, queueNameFn: (entityId: string) => string, workerNameFn: (entityId: string) => string): void;
65
- /**
66
- * Listen for job arrivals on a specific queue.
67
- * Creates a QueueEvents instance for the queue and listens for 'waiting' events.
68
- *
69
- * @param queueName The BullMQ queue name to listen to
70
- * @param entityType The entity type (e.g., 'table')
71
- * @param extractEntityId Function to extract entityId from queue name
72
- */
73
- listenToQueue(queueName: string, entityType: string, extractEntityId: (queueName: string) => string): Promise<void>;
74
- /**
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.
84
- */
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;
96
- /**
97
- * Listen to all queues that match a pattern.
98
- * Uses Redis SCAN to find existing queues and listens to them.
99
- * Also sets up keyspace notifications for new queues (if enabled).
100
- */
101
- listenToEntityTypeQueues(entityType: string): Promise<void>;
102
- /**
103
- * Ensure we're listening to events for a specific queue.
104
- * Call this when adding a job to ensure we catch the event.
105
- */
106
- ensureListening(queueName: string, entityType: string): Promise<void>;
107
- /**
108
- * Stop listening to a specific queue.
109
- */
110
- stopListening(queueName: string): Promise<void>;
111
- /**
112
- * Get all registered queue names.
113
- */
114
- getRegisteredQueues(): string[];
115
- /**
116
- * Cleanup on module destroy.
117
- */
118
- onModuleDestroy(): Promise<void>;
119
- }
120
- //# sourceMappingURL=queue-events-manager.service.d.ts.map
@@ -1 +0,0 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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