@tachybase/plugin-adapter-bullmq 1.3.16 → 1.3.18

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 (348) hide show
  1. package/dist/externalVersion.js +2 -2
  2. package/dist/index.js +4 -4
  3. package/dist/node_modules/@bull-board/api/dist/src/handlers/error.d.ts +4 -2
  4. package/dist/node_modules/@bull-board/api/dist/src/handlers/error.js +2 -2
  5. package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseAll.d.ts +4 -0
  6. package/dist/node_modules/@bull-board/api/dist/src/handlers/pauseAll.js +15 -0
  7. package/dist/node_modules/@bull-board/api/dist/src/handlers/queues.js +4 -0
  8. package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeAll.d.ts +4 -0
  9. package/dist/node_modules/@bull-board/api/dist/src/handlers/resumeAll.js +15 -0
  10. package/dist/node_modules/@bull-board/api/dist/src/index.js +1 -1
  11. package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.d.ts +4 -0
  12. package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/base.js +6 -0
  13. package/dist/node_modules/@bull-board/api/dist/src/queueAdapters/bull.js +6 -4
  14. package/dist/node_modules/@bull-board/api/dist/src/routes.js +4 -0
  15. package/dist/node_modules/@bull-board/api/dist/typings/app.d.ts +22 -2
  16. package/dist/node_modules/@bull-board/api/package.json +1 -1
  17. package/dist/node_modules/@bull-board/koa/dist/KoaAdapter.js +1 -1
  18. package/dist/node_modules/@bull-board/koa/dist/index.js +101 -101
  19. package/dist/node_modules/@bull-board/koa/package.json +1 -1
  20. package/dist/node_modules/bullmq/dist/cjs/classes/backoffs.js +18 -5
  21. package/dist/node_modules/bullmq/dist/cjs/classes/child-pool.js +7 -2
  22. package/dist/node_modules/bullmq/dist/cjs/classes/child-processor.js +59 -5
  23. package/dist/node_modules/bullmq/dist/cjs/classes/child.js +3 -1
  24. package/dist/node_modules/bullmq/dist/cjs/classes/errors/index.js +2 -1
  25. package/dist/node_modules/bullmq/dist/cjs/classes/errors/waiting-error.js +19 -0
  26. package/dist/node_modules/bullmq/dist/cjs/classes/flow-producer.js +21 -5
  27. package/dist/node_modules/bullmq/dist/cjs/classes/index.js +1 -0
  28. package/dist/node_modules/bullmq/dist/cjs/classes/job-scheduler.js +88 -62
  29. package/dist/node_modules/bullmq/dist/cjs/classes/job.js +216 -109
  30. package/dist/node_modules/bullmq/dist/cjs/classes/main-base.js +1 -1
  31. package/dist/node_modules/bullmq/dist/cjs/classes/queue-base.js +10 -9
  32. package/dist/node_modules/bullmq/dist/cjs/classes/queue-getters.js +34 -14
  33. package/dist/node_modules/bullmq/dist/cjs/classes/queue.js +19 -13
  34. package/dist/node_modules/bullmq/dist/cjs/classes/redis-connection.js +16 -9
  35. package/dist/node_modules/bullmq/dist/cjs/classes/repeat.js +1 -1
  36. package/dist/node_modules/bullmq/dist/cjs/classes/sandbox.js +54 -28
  37. package/dist/node_modules/bullmq/dist/cjs/classes/scripts.js +141 -39
  38. package/dist/node_modules/bullmq/dist/cjs/classes/worker.js +191 -182
  39. package/dist/node_modules/bullmq/dist/cjs/commands/addDelayedJob-6.lua +6 -17
  40. package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-11.lua +123 -0
  41. package/dist/node_modules/bullmq/dist/{esm/commands/addParentJob-4.lua → cjs/commands/addParentJob-5.lua} +7 -6
  42. package/dist/node_modules/bullmq/dist/cjs/commands/{addPrioritizedJob-8.lua → addPrioritizedJob-9.lua} +11 -10
  43. package/dist/node_modules/bullmq/dist/cjs/commands/addRepeatableJob-2.lua +2 -2
  44. package/dist/node_modules/bullmq/dist/{esm/commands/addStandardJob-8.lua → cjs/commands/addStandardJob-9.lua} +9 -8
  45. package/dist/node_modules/bullmq/dist/cjs/commands/cleanJobsInSet-3.lua +9 -5
  46. package/dist/node_modules/bullmq/dist/cjs/commands/drain-5.lua +16 -16
  47. package/dist/node_modules/bullmq/dist/cjs/commands/getDependencyCounts-4.lua +31 -0
  48. package/dist/node_modules/bullmq/dist/cjs/commands/getState-8.lua +5 -5
  49. package/dist/node_modules/bullmq/dist/cjs/commands/getStateV2-8.lua +8 -8
  50. package/dist/node_modules/bullmq/dist/cjs/commands/includes/addDelayedJob.lua +23 -0
  51. package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobFromScheduler.lua +37 -0
  52. package/dist/node_modules/bullmq/dist/cjs/commands/includes/addJobWithPriority.lua +2 -2
  53. package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanList.lua +4 -2
  54. package/dist/node_modules/bullmq/dist/cjs/commands/includes/cleanSet.lua +3 -11
  55. package/dist/node_modules/bullmq/dist/cjs/commands/includes/collectMetrics.lua +1 -1
  56. package/dist/node_modules/bullmq/dist/cjs/commands/includes/deduplicateJob.lua +63 -18
  57. package/dist/node_modules/bullmq/dist/cjs/commands/includes/filterOutJobsToIgnore.lua +14 -0
  58. package/dist/node_modules/bullmq/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +1 -1
  59. package/dist/node_modules/bullmq/dist/cjs/commands/includes/getOrSetMaxEvents.lua +6 -6
  60. package/dist/node_modules/bullmq/dist/cjs/commands/includes/getPriorityScore.lua +8 -0
  61. package/dist/node_modules/bullmq/dist/cjs/commands/includes/isJobSchedulerJob.lua +15 -0
  62. package/dist/node_modules/bullmq/dist/cjs/commands/includes/isLocked.lua +1 -0
  63. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +77 -0
  64. package/dist/node_modules/bullmq/dist/cjs/commands/includes/{moveJobFromPriorityToActive.lua → moveJobFromPrioritizedToActive.lua} +1 -1
  65. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWait.lua +45 -0
  66. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  67. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  68. package/dist/node_modules/bullmq/dist/cjs/commands/includes/prepareJobForProcessing.lua +2 -1
  69. package/dist/node_modules/bullmq/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -3
  70. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  71. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  72. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJob.lua +2 -2
  73. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobKeys.lua +2 -2
  74. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeJobWithChildren.lua +95 -0
  75. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeListJobs.lua +7 -1
  76. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeParentDependencyKey.lua +5 -5
  77. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeZSetJobs.lua +2 -8
  78. package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJob.lua +2 -2
  79. package/dist/node_modules/bullmq/dist/cjs/commands/includes/storeJobScheduler.lua +52 -0
  80. package/dist/node_modules/bullmq/dist/cjs/commands/includes/trimEvents.lua +1 -1
  81. package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateExistingJobsParent.lua +1 -1
  82. package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateJobFields.lua +5 -5
  83. package/dist/node_modules/bullmq/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  84. package/dist/node_modules/bullmq/dist/cjs/commands/isFinished-3.lua +2 -2
  85. package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-9.lua +63 -0
  86. package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-8.lua +109 -0
  87. package/dist/node_modules/bullmq/dist/cjs/commands/moveToActive-11.lua +3 -2
  88. package/dist/node_modules/bullmq/dist/cjs/commands/moveToFinished-14.lua +52 -52
  89. package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-8.lua +106 -0
  90. package/dist/node_modules/bullmq/dist/cjs/commands/removeJob-2.lua +18 -66
  91. package/dist/node_modules/bullmq/dist/cjs/commands/removeJobScheduler-3.lua +1 -1
  92. package/dist/node_modules/bullmq/dist/cjs/commands/removeUnprocessedChildren-2.lua +31 -0
  93. package/dist/node_modules/bullmq/dist/cjs/commands/retryJob-11.lua +11 -5
  94. package/dist/node_modules/bullmq/dist/cjs/commands/updateJobScheduler-12.lua +90 -0
  95. package/dist/node_modules/bullmq/dist/cjs/commands/updateRepeatableJobMillis-1.lua +1 -1
  96. package/dist/node_modules/bullmq/dist/cjs/enums/child-command.js +2 -0
  97. package/dist/node_modules/bullmq/dist/cjs/enums/error-code.js +2 -1
  98. package/dist/node_modules/bullmq/dist/cjs/enums/parent-command.js +5 -2
  99. package/dist/node_modules/bullmq/dist/cjs/index.js +1 -1
  100. package/dist/node_modules/bullmq/dist/cjs/interfaces/index.js +2 -1
  101. package/dist/node_modules/bullmq/dist/cjs/interfaces/{debounce-options.js → parent-options.js} +1 -1
  102. package/dist/node_modules/bullmq/dist/cjs/interfaces/receiver.js +3 -0
  103. package/dist/node_modules/bullmq/dist/cjs/scripts/addDelayedJob-6.js +163 -84
  104. package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-11.js +465 -0
  105. package/dist/node_modules/bullmq/dist/cjs/scripts/{addParentJob-4.js → addParentJob-5.js} +147 -75
  106. package/dist/node_modules/bullmq/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-9.js} +151 -79
  107. package/dist/node_modules/bullmq/dist/cjs/scripts/addRepeatableJob-2.js +18 -13
  108. package/dist/node_modules/bullmq/dist/cjs/scripts/{addStandardJob-8.js → addStandardJob-9.js} +149 -77
  109. package/dist/node_modules/bullmq/dist/cjs/scripts/changeDelay-4.js +7 -7
  110. package/dist/node_modules/bullmq/dist/cjs/scripts/changePriority-7.js +8 -2
  111. package/dist/node_modules/bullmq/dist/cjs/scripts/cleanJobsInSet-3.js +45 -29
  112. package/dist/node_modules/bullmq/dist/cjs/scripts/drain-5.js +49 -35
  113. package/dist/node_modules/bullmq/dist/cjs/scripts/getDependencyCounts-4.js +37 -0
  114. package/dist/node_modules/bullmq/dist/cjs/scripts/getState-8.js +5 -5
  115. package/dist/node_modules/bullmq/dist/cjs/scripts/getStateV2-8.js +8 -8
  116. package/dist/node_modules/bullmq/dist/cjs/scripts/index.js +10 -7
  117. package/dist/node_modules/bullmq/dist/cjs/scripts/isFinished-3.js +2 -2
  118. package/dist/node_modules/bullmq/dist/cjs/scripts/{moveJobFromActiveToWait-10.js → moveJobFromActiveToWait-9.js} +57 -37
  119. package/dist/node_modules/bullmq/dist/cjs/scripts/moveJobsToWait-8.js +6 -6
  120. package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-8.js +171 -0
  121. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToActive-11.js +18 -8
  122. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToDelayed-8.js +12 -12
  123. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToFinished-14.js +218 -155
  124. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-8.js +529 -0
  125. package/dist/node_modules/bullmq/dist/cjs/scripts/obliterate-2.js +33 -20
  126. package/dist/node_modules/bullmq/dist/cjs/scripts/pause-7.js +1 -1
  127. package/dist/node_modules/bullmq/dist/cjs/scripts/promote-9.js +8 -2
  128. package/dist/node_modules/bullmq/dist/cjs/scripts/removeChildDependency-1.js +7 -7
  129. package/dist/node_modules/bullmq/dist/cjs/scripts/removeJob-2.js +120 -63
  130. package/dist/node_modules/bullmq/dist/cjs/scripts/removeJobScheduler-3.js +3 -3
  131. package/dist/node_modules/bullmq/dist/cjs/scripts/removeRepeatable-3.js +2 -2
  132. package/dist/node_modules/bullmq/dist/cjs/scripts/removeUnprocessedChildren-2.js +339 -0
  133. package/dist/node_modules/bullmq/dist/cjs/scripts/reprocessJob-8.js +6 -6
  134. package/dist/node_modules/bullmq/dist/cjs/scripts/retryJob-11.js +47 -26
  135. package/dist/node_modules/bullmq/dist/cjs/scripts/updateJobScheduler-12.js +274 -0
  136. package/dist/node_modules/bullmq/dist/cjs/scripts/updateProgress-3.js +6 -6
  137. package/dist/node_modules/bullmq/dist/cjs/scripts/updateRepeatableJobMillis-1.js +1 -1
  138. package/dist/node_modules/bullmq/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  139. package/dist/node_modules/bullmq/dist/cjs/types/deduplication-options.js +3 -0
  140. package/dist/node_modules/bullmq/dist/cjs/types/index.js +3 -0
  141. package/dist/node_modules/bullmq/dist/cjs/types/job-progress.js +3 -0
  142. package/dist/node_modules/bullmq/dist/cjs/types/script-queue-context.js +3 -0
  143. package/dist/node_modules/bullmq/dist/cjs/utils.js +29 -1
  144. package/dist/node_modules/bullmq/dist/cjs/version.js +1 -1
  145. package/dist/node_modules/bullmq/dist/esm/classes/backoffs.d.ts +1 -1
  146. package/dist/node_modules/bullmq/dist/esm/classes/backoffs.js +18 -5
  147. package/dist/node_modules/bullmq/dist/esm/classes/child-pool.d.ts +1 -1
  148. package/dist/node_modules/bullmq/dist/esm/classes/child-pool.js +7 -2
  149. package/dist/node_modules/bullmq/dist/esm/classes/child-processor.d.ts +3 -2
  150. package/dist/node_modules/bullmq/dist/esm/classes/child-processor.js +59 -5
  151. package/dist/node_modules/bullmq/dist/esm/classes/child.js +3 -1
  152. package/dist/node_modules/bullmq/dist/esm/classes/errors/index.d.ts +2 -1
  153. package/dist/node_modules/bullmq/dist/esm/classes/errors/index.js +2 -1
  154. package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-error.d.ts +10 -0
  155. package/dist/node_modules/bullmq/dist/esm/classes/errors/waiting-error.js +15 -0
  156. package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.d.ts +3 -9
  157. package/dist/node_modules/bullmq/dist/esm/classes/flow-producer.js +21 -5
  158. package/dist/node_modules/bullmq/dist/esm/classes/index.d.ts +1 -0
  159. package/dist/node_modules/bullmq/dist/esm/classes/index.js +1 -0
  160. package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.d.ts +2 -2
  161. package/dist/node_modules/bullmq/dist/esm/classes/job-scheduler.js +88 -62
  162. package/dist/node_modules/bullmq/dist/esm/classes/job.d.ts +69 -19
  163. package/dist/node_modules/bullmq/dist/esm/classes/job.js +217 -110
  164. package/dist/node_modules/bullmq/dist/esm/classes/main-base.d.ts +2 -3
  165. package/dist/node_modules/bullmq/dist/esm/classes/main-base.js +1 -1
  166. package/dist/node_modules/bullmq/dist/esm/classes/queue-base.d.ts +2 -5
  167. package/dist/node_modules/bullmq/dist/esm/classes/queue-base.js +11 -10
  168. package/dist/node_modules/bullmq/dist/esm/classes/queue-events-producer.d.ts +2 -2
  169. package/dist/node_modules/bullmq/dist/esm/classes/queue-events.d.ts +118 -29
  170. package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.d.ts +20 -13
  171. package/dist/node_modules/bullmq/dist/esm/classes/queue-getters.js +34 -14
  172. package/dist/node_modules/bullmq/dist/esm/classes/queue.d.ts +19 -16
  173. package/dist/node_modules/bullmq/dist/esm/classes/queue.js +19 -13
  174. package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.d.ts +7 -3
  175. package/dist/node_modules/bullmq/dist/esm/classes/redis-connection.js +16 -9
  176. package/dist/node_modules/bullmq/dist/esm/classes/repeat.js +1 -1
  177. package/dist/node_modules/bullmq/dist/esm/classes/sandbox.js +54 -28
  178. package/dist/node_modules/bullmq/dist/esm/classes/scripts.d.ts +20 -13
  179. package/dist/node_modules/bullmq/dist/esm/classes/scripts.js +141 -39
  180. package/dist/node_modules/bullmq/dist/esm/classes/worker.d.ts +28 -7
  181. package/dist/node_modules/bullmq/dist/esm/classes/worker.js +192 -183
  182. package/dist/node_modules/bullmq/dist/esm/commands/addDelayedJob-6.lua +6 -17
  183. package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-11.lua +123 -0
  184. package/dist/node_modules/bullmq/dist/{cjs/commands/addParentJob-4.lua → esm/commands/addParentJob-5.lua} +7 -6
  185. package/dist/node_modules/bullmq/dist/esm/commands/{addPrioritizedJob-8.lua → addPrioritizedJob-9.lua} +11 -10
  186. package/dist/node_modules/bullmq/dist/esm/commands/addRepeatableJob-2.lua +2 -2
  187. package/dist/node_modules/bullmq/dist/{cjs/commands/addStandardJob-8.lua → esm/commands/addStandardJob-9.lua} +9 -8
  188. package/dist/node_modules/bullmq/dist/esm/commands/cleanJobsInSet-3.lua +9 -5
  189. package/dist/node_modules/bullmq/dist/esm/commands/drain-5.lua +16 -16
  190. package/dist/node_modules/bullmq/dist/esm/commands/getDependencyCounts-4.lua +31 -0
  191. package/dist/node_modules/bullmq/dist/esm/commands/getState-8.lua +5 -5
  192. package/dist/node_modules/bullmq/dist/esm/commands/getStateV2-8.lua +8 -8
  193. package/dist/node_modules/bullmq/dist/esm/commands/includes/addDelayedJob.lua +23 -0
  194. package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobFromScheduler.lua +37 -0
  195. package/dist/node_modules/bullmq/dist/esm/commands/includes/addJobWithPriority.lua +2 -2
  196. package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanList.lua +4 -2
  197. package/dist/node_modules/bullmq/dist/esm/commands/includes/cleanSet.lua +3 -11
  198. package/dist/node_modules/bullmq/dist/esm/commands/includes/collectMetrics.lua +1 -1
  199. package/dist/node_modules/bullmq/dist/esm/commands/includes/deduplicateJob.lua +63 -18
  200. package/dist/node_modules/bullmq/dist/esm/commands/includes/filterOutJobsToIgnore.lua +14 -0
  201. package/dist/node_modules/bullmq/dist/esm/commands/includes/getNextDelayedTimestamp.lua +1 -1
  202. package/dist/node_modules/bullmq/dist/esm/commands/includes/getOrSetMaxEvents.lua +6 -6
  203. package/dist/node_modules/bullmq/dist/esm/commands/includes/getPriorityScore.lua +8 -0
  204. package/dist/node_modules/bullmq/dist/esm/commands/includes/isJobSchedulerJob.lua +15 -0
  205. package/dist/node_modules/bullmq/dist/esm/commands/includes/isLocked.lua +1 -0
  206. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +77 -0
  207. package/dist/node_modules/bullmq/dist/esm/commands/includes/{moveJobFromPriorityToActive.lua → moveJobFromPrioritizedToActive.lua} +1 -1
  208. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWait.lua +45 -0
  209. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  210. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  211. package/dist/node_modules/bullmq/dist/esm/commands/includes/prepareJobForProcessing.lua +2 -1
  212. package/dist/node_modules/bullmq/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -3
  213. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  214. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  215. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJob.lua +2 -2
  216. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobKeys.lua +2 -2
  217. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeJobWithChildren.lua +95 -0
  218. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeListJobs.lua +7 -1
  219. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeParentDependencyKey.lua +5 -5
  220. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeZSetJobs.lua +2 -8
  221. package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJob.lua +2 -2
  222. package/dist/node_modules/bullmq/dist/esm/commands/includes/storeJobScheduler.lua +52 -0
  223. package/dist/node_modules/bullmq/dist/esm/commands/includes/trimEvents.lua +1 -1
  224. package/dist/node_modules/bullmq/dist/esm/commands/includes/updateExistingJobsParent.lua +1 -1
  225. package/dist/node_modules/bullmq/dist/esm/commands/includes/updateJobFields.lua +5 -5
  226. package/dist/node_modules/bullmq/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  227. package/dist/node_modules/bullmq/dist/esm/commands/isFinished-3.lua +2 -2
  228. package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-9.lua +63 -0
  229. package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-8.lua +109 -0
  230. package/dist/node_modules/bullmq/dist/esm/commands/moveToActive-11.lua +3 -2
  231. package/dist/node_modules/bullmq/dist/esm/commands/moveToFinished-14.lua +52 -52
  232. package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-8.lua +106 -0
  233. package/dist/node_modules/bullmq/dist/esm/commands/removeJob-2.lua +18 -66
  234. package/dist/node_modules/bullmq/dist/esm/commands/removeJobScheduler-3.lua +1 -1
  235. package/dist/node_modules/bullmq/dist/esm/commands/removeUnprocessedChildren-2.lua +31 -0
  236. package/dist/node_modules/bullmq/dist/esm/commands/retryJob-11.lua +11 -5
  237. package/dist/node_modules/bullmq/dist/esm/commands/updateJobScheduler-12.lua +90 -0
  238. package/dist/node_modules/bullmq/dist/esm/commands/updateRepeatableJobMillis-1.lua +1 -1
  239. package/dist/node_modules/bullmq/dist/esm/enums/child-command.d.ts +3 -1
  240. package/dist/node_modules/bullmq/dist/esm/enums/child-command.js +2 -0
  241. package/dist/node_modules/bullmq/dist/esm/enums/error-code.d.ts +3 -2
  242. package/dist/node_modules/bullmq/dist/esm/enums/error-code.js +2 -1
  243. package/dist/node_modules/bullmq/dist/esm/enums/parent-command.d.ts +5 -2
  244. package/dist/node_modules/bullmq/dist/esm/enums/parent-command.js +5 -2
  245. package/dist/node_modules/bullmq/dist/esm/interfaces/backoff-options.d.ts +5 -0
  246. package/dist/node_modules/bullmq/dist/esm/interfaces/base-job-options.d.ts +3 -9
  247. package/dist/node_modules/bullmq/dist/esm/interfaces/child-message.d.ts +1 -0
  248. package/dist/node_modules/bullmq/dist/esm/interfaces/index.d.ts +2 -1
  249. package/dist/node_modules/bullmq/dist/esm/interfaces/index.js +2 -1
  250. package/dist/node_modules/bullmq/dist/esm/interfaces/job-json.d.ts +6 -2
  251. package/dist/node_modules/bullmq/dist/esm/interfaces/job-scheduler-json.d.ts +7 -4
  252. package/dist/node_modules/bullmq/dist/esm/interfaces/minimal-job.d.ts +34 -15
  253. package/dist/node_modules/bullmq/dist/esm/interfaces/parent-options.d.ts +11 -0
  254. package/dist/node_modules/bullmq/dist/esm/interfaces/parent-options.js +2 -0
  255. package/dist/node_modules/bullmq/dist/esm/interfaces/parent.d.ts +6 -2
  256. package/dist/node_modules/bullmq/dist/esm/interfaces/queue-options.d.ts +15 -6
  257. package/dist/node_modules/bullmq/dist/esm/interfaces/receiver.d.ts +4 -0
  258. package/dist/node_modules/bullmq/dist/esm/interfaces/receiver.js +2 -0
  259. package/dist/node_modules/bullmq/dist/esm/interfaces/repeat-options.d.ts +1 -2
  260. package/dist/node_modules/bullmq/dist/esm/interfaces/repeatable-options.d.ts +2 -0
  261. package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-job.d.ts +3 -2
  262. package/dist/node_modules/bullmq/dist/esm/interfaces/sandboxed-options.d.ts +1 -1
  263. package/dist/node_modules/bullmq/dist/esm/interfaces/telemetry.d.ts +18 -15
  264. package/dist/node_modules/bullmq/dist/esm/interfaces/worker-options.d.ts +10 -10
  265. package/dist/node_modules/bullmq/dist/esm/scripts/addDelayedJob-6.js +163 -84
  266. package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-11.js +462 -0
  267. package/dist/node_modules/bullmq/dist/esm/scripts/{addParentJob-4.js → addParentJob-5.js} +147 -75
  268. package/dist/node_modules/bullmq/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-9.js} +151 -79
  269. package/dist/node_modules/bullmq/dist/esm/scripts/addRepeatableJob-2.js +18 -13
  270. package/dist/node_modules/bullmq/dist/esm/scripts/{addStandardJob-8.js → addStandardJob-9.js} +149 -77
  271. package/dist/node_modules/bullmq/dist/esm/scripts/changeDelay-4.js +7 -7
  272. package/dist/node_modules/bullmq/dist/esm/scripts/changePriority-7.js +8 -2
  273. package/dist/node_modules/bullmq/dist/esm/scripts/cleanJobsInSet-3.js +45 -29
  274. package/dist/node_modules/bullmq/dist/esm/scripts/drain-5.js +49 -35
  275. package/dist/node_modules/bullmq/dist/esm/scripts/getDependencyCounts-4.d.ts +5 -0
  276. package/dist/node_modules/bullmq/dist/esm/scripts/getDependencyCounts-4.js +34 -0
  277. package/dist/node_modules/bullmq/dist/esm/scripts/getState-8.js +5 -5
  278. package/dist/node_modules/bullmq/dist/esm/scripts/getStateV2-8.js +8 -8
  279. package/dist/node_modules/bullmq/dist/esm/scripts/index.d.ts +10 -7
  280. package/dist/node_modules/bullmq/dist/esm/scripts/index.js +10 -7
  281. package/dist/node_modules/bullmq/dist/esm/scripts/isFinished-3.js +2 -2
  282. package/dist/node_modules/bullmq/dist/esm/scripts/{moveJobFromActiveToWait-10.js → moveJobFromActiveToWait-9.js} +57 -37
  283. package/dist/node_modules/bullmq/dist/esm/scripts/moveJobsToWait-8.js +6 -6
  284. package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-8.js +168 -0
  285. package/dist/node_modules/bullmq/dist/esm/scripts/moveToActive-11.js +18 -8
  286. package/dist/node_modules/bullmq/dist/esm/scripts/moveToDelayed-8.js +12 -12
  287. package/dist/node_modules/bullmq/dist/esm/scripts/moveToFinished-14.js +218 -155
  288. package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-8.js +526 -0
  289. package/dist/node_modules/bullmq/dist/esm/scripts/obliterate-2.js +33 -20
  290. package/dist/node_modules/bullmq/dist/esm/scripts/pause-7.js +1 -1
  291. package/dist/node_modules/bullmq/dist/esm/scripts/promote-9.js +8 -2
  292. package/dist/node_modules/bullmq/dist/esm/scripts/removeChildDependency-1.js +7 -7
  293. package/dist/node_modules/bullmq/dist/esm/scripts/removeJob-2.js +120 -63
  294. package/dist/node_modules/bullmq/dist/esm/scripts/removeJobScheduler-3.js +3 -3
  295. package/dist/node_modules/bullmq/dist/esm/scripts/removeRepeatable-3.js +2 -2
  296. package/dist/node_modules/bullmq/dist/esm/scripts/removeUnprocessedChildren-2.d.ts +5 -0
  297. package/dist/node_modules/bullmq/dist/esm/scripts/removeUnprocessedChildren-2.js +336 -0
  298. package/dist/node_modules/bullmq/dist/esm/scripts/reprocessJob-8.js +6 -6
  299. package/dist/node_modules/bullmq/dist/esm/scripts/retryJob-11.js +47 -26
  300. package/dist/node_modules/bullmq/dist/esm/scripts/updateJobScheduler-12.d.ts +5 -0
  301. package/dist/node_modules/bullmq/dist/esm/scripts/updateJobScheduler-12.js +271 -0
  302. package/dist/node_modules/bullmq/dist/esm/scripts/updateProgress-3.js +6 -6
  303. package/dist/node_modules/bullmq/dist/esm/scripts/updateRepeatableJobMillis-1.js +1 -1
  304. package/dist/node_modules/bullmq/dist/esm/tsconfig.tsbuildinfo +1 -1
  305. package/dist/node_modules/bullmq/dist/esm/types/deduplication-options.d.ts +22 -0
  306. package/dist/node_modules/bullmq/dist/esm/types/deduplication-options.js +2 -0
  307. package/dist/node_modules/bullmq/dist/esm/types/index.d.ts +3 -0
  308. package/dist/node_modules/bullmq/dist/esm/types/index.js +3 -0
  309. package/dist/node_modules/bullmq/dist/esm/types/job-options.d.ts +19 -8
  310. package/dist/node_modules/bullmq/dist/esm/types/job-progress.d.ts +1 -0
  311. package/dist/node_modules/bullmq/dist/esm/types/job-progress.js +2 -0
  312. package/dist/node_modules/bullmq/dist/esm/types/script-queue-context.d.ts +2 -0
  313. package/dist/node_modules/bullmq/dist/esm/types/script-queue-context.js +2 -0
  314. package/dist/node_modules/bullmq/dist/esm/utils.d.ts +25 -5
  315. package/dist/node_modules/bullmq/dist/esm/utils.js +27 -0
  316. package/dist/node_modules/bullmq/dist/esm/version.d.ts +1 -1
  317. package/dist/node_modules/bullmq/dist/esm/version.js +1 -1
  318. package/dist/node_modules/bullmq/package.json +1 -1
  319. package/package.json +7 -7
  320. package/dist/node_modules/bullmq/dist/cjs/commands/addJobScheduler-2.lua +0 -91
  321. package/dist/node_modules/bullmq/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -53
  322. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
  323. package/dist/node_modules/bullmq/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  324. package/dist/node_modules/bullmq/dist/cjs/commands/moveJobFromActiveToWait-10.lua +0 -60
  325. package/dist/node_modules/bullmq/dist/cjs/commands/moveStalledJobsToWait-9.lua +0 -156
  326. package/dist/node_modules/bullmq/dist/cjs/commands/moveToWaitingChildren-5.lua +0 -68
  327. package/dist/node_modules/bullmq/dist/cjs/scripts/addJobScheduler-2.js +0 -237
  328. package/dist/node_modules/bullmq/dist/cjs/scripts/moveStalledJobsToWait-9.js +0 -529
  329. package/dist/node_modules/bullmq/dist/cjs/scripts/moveToWaitingChildren-5.js +0 -83
  330. package/dist/node_modules/bullmq/dist/esm/commands/addJobScheduler-2.lua +0 -91
  331. package/dist/node_modules/bullmq/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -53
  332. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
  333. package/dist/node_modules/bullmq/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  334. package/dist/node_modules/bullmq/dist/esm/commands/moveJobFromActiveToWait-10.lua +0 -60
  335. package/dist/node_modules/bullmq/dist/esm/commands/moveStalledJobsToWait-9.lua +0 -156
  336. package/dist/node_modules/bullmq/dist/esm/commands/moveToWaitingChildren-5.lua +0 -68
  337. package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.d.ts +0 -13
  338. package/dist/node_modules/bullmq/dist/esm/interfaces/debounce-options.js +0 -2
  339. package/dist/node_modules/bullmq/dist/esm/scripts/addJobScheduler-2.js +0 -234
  340. package/dist/node_modules/bullmq/dist/esm/scripts/moveStalledJobsToWait-9.js +0 -526
  341. package/dist/node_modules/bullmq/dist/esm/scripts/moveToWaitingChildren-5.js +0 -80
  342. /package/dist/node_modules/bullmq/dist/esm/scripts/{addJobScheduler-2.d.ts → addJobScheduler-11.d.ts} +0 -0
  343. /package/dist/node_modules/bullmq/dist/esm/scripts/{addParentJob-4.d.ts → addParentJob-5.d.ts} +0 -0
  344. /package/dist/node_modules/bullmq/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-9.d.ts} +0 -0
  345. /package/dist/node_modules/bullmq/dist/esm/scripts/{addStandardJob-8.d.ts → addStandardJob-9.d.ts} +0 -0
  346. /package/dist/node_modules/bullmq/dist/esm/scripts/{moveJobFromActiveToWait-10.d.ts → moveJobFromActiveToWait-9.d.ts} +0 -0
  347. /package/dist/node_modules/bullmq/dist/esm/scripts/{moveStalledJobsToWait-9.d.ts → moveStalledJobsToWait-8.d.ts} +0 -0
  348. /package/dist/node_modules/bullmq/dist/esm/scripts/{moveToWaitingChildren-5.d.ts → moveToWaitingChildren-8.d.ts} +0 -0
@@ -11,6 +11,7 @@ const content = `--[[
11
11
  KEYS[4] 'prioritized'
12
12
  KEYS[5] 'jobschedulers' (repeat)
13
13
  ARGV[1] queue key prefix
14
+ ARGV[2] should clean delayed jobs
14
15
  ]]
15
16
  local rcall = redis.call
16
17
  local queueBaseKey = ARGV[1]
@@ -18,6 +19,18 @@ local queueBaseKey = ARGV[1]
18
19
  Functions to remove jobs.
19
20
  ]]
20
21
  -- Includes
22
+ --[[
23
+ Function to filter out jobs to ignore from a table.
24
+ ]]
25
+ local function filterOutJobsToIgnore(jobs, jobsToIgnore)
26
+ local filteredJobs = {}
27
+ for i = 1, #jobs do
28
+ if not jobsToIgnore[jobs[i]] then
29
+ table.insert(filteredJobs, jobs[i])
30
+ end
31
+ end
32
+ return filteredJobs
33
+ end
21
34
  --[[
22
35
  Functions to remove jobs.
23
36
  ]]
@@ -27,21 +40,26 @@ local queueBaseKey = ARGV[1]
27
40
  ]]
28
41
  -- Includes
29
42
  --[[
30
- Function to remove deduplication key.
43
+ Function to remove deduplication key if needed
44
+ when a job is being removed.
31
45
  ]]
32
- local function removeDeduplicationKey(prefixKey, jobKey)
46
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
47
+ jobKey, jobId)
33
48
  local deduplicationId = rcall("HGET", jobKey, "deid")
34
49
  if deduplicationId then
35
50
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
36
- rcall("DEL", deduplicationKey)
51
+ local currentJobId = rcall('GET', deduplicationKey)
52
+ if currentJobId and currentJobId == jobId then
53
+ return rcall("DEL", deduplicationKey)
54
+ end
37
55
  end
38
56
  end
39
57
  --[[
40
58
  Function to remove job keys.
41
59
  ]]
42
60
  local function removeJobKeys(jobKey)
43
- return rcall("DEL", jobKey, jobKey .. ':logs',
44
- jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
61
+ return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
62
+ jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
45
63
  end
46
64
  --[[
47
65
  Check if this job has a parent. If so we will just remove it from
@@ -95,7 +113,7 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
95
113
  end
96
114
  return waitKey, false
97
115
  end
98
- local function moveParentToWait(parentPrefix, parentId, emitEvent)
116
+ local function _moveParentToWait(parentPrefix, parentId, emitEvent)
99
117
  local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
100
118
  parentPrefix .. "wait", parentPrefix .. "paused")
101
119
  addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
@@ -123,10 +141,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
123
141
  rcall("DEL", parentPrefix .. "de:" .. debounceId)
124
142
  end
125
143
  else
126
- moveParentToWait(parentPrefix, parentId)
144
+ _moveParentToWait(parentPrefix, parentId)
127
145
  end
128
146
  else
129
- moveParentToWait(parentPrefix, parentId, true)
147
+ _moveParentToWait(parentPrefix, parentId, true)
130
148
  end
131
149
  end
132
150
  end
@@ -154,10 +172,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
154
172
  rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
155
173
  end
156
174
  else
157
- moveParentToWait(parentPrefix, parentId)
175
+ _moveParentToWait(parentPrefix, parentId)
158
176
  end
159
177
  else
160
- moveParentToWait(parentPrefix, parentId, true)
178
+ _moveParentToWait(parentPrefix, parentId, true)
161
179
  end
162
180
  end
163
181
  end
@@ -171,7 +189,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
171
189
  local jobKey = baseKey .. jobId
172
190
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
173
191
  if shouldRemoveDeduplicationKey then
174
- removeDeduplicationKey(baseKey, jobKey)
192
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
175
193
  end
176
194
  removeJobKeys(jobKey)
177
195
  end
@@ -184,8 +202,11 @@ end
184
202
  local function getListItems(keyName, max)
185
203
  return rcall('LRANGE', keyName, 0, max - 1)
186
204
  end
187
- local function removeListJobs(keyName, hard, baseKey, max)
205
+ local function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)
188
206
  local jobs = getListItems(keyName, max)
207
+ if jobsToIgnore then
208
+ jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
209
+ end
189
210
  local count = removeJobs(jobs, hard, baseKey, max)
190
211
  rcall("LTRIM", keyName, #jobs, -1)
191
212
  return count
@@ -215,15 +236,8 @@ local function getZSetItems(keyName, max)
215
236
  end
216
237
  local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
217
238
  local jobs = getZSetItems(keyName, max)
218
- -- filter out jobs to ignore
219
239
  if jobsToIgnore then
220
- local filteredJobs = {}
221
- for i = 1, #jobs do
222
- if not jobsToIgnore[jobs[i]] then
223
- table.insert(filteredJobs, jobs[i])
224
- end
225
- end
226
- jobs = filteredJobs
240
+ jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
227
241
  end
228
242
  local count = removeJobs(jobs, hard, baseKey, max)
229
243
  if(#jobs > 0) then
@@ -233,22 +247,22 @@ local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
233
247
  end
234
248
  return count
235
249
  end
236
- removeListJobs(KEYS[1], true, queueBaseKey, 0) -- wait
237
- removeListJobs(KEYS[2], true, queueBaseKey, 0) -- paused
238
- if KEYS[3] ~= "" then
239
- -- We must not remove delayed jobs if they are associated to a job scheduler.
240
- local scheduledJobs = {}
241
- local jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")
242
- -- For every job scheduler, get the current delayed job id.
243
- for i = 1, #jobSchedulers, 2 do
244
- local jobSchedulerId = jobSchedulers[i]
245
- local jobSchedulerMillis = jobSchedulers[i + 1]
246
- local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis
247
- scheduledJobs[delayedJobId] = true
248
- end
249
- removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed
250
+ -- We must not remove delayed jobs if they are associated to a job scheduler.
251
+ local scheduledJobs = {}
252
+ local jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")
253
+ -- For every job scheduler, get the current delayed job id.
254
+ for i = 1, #jobSchedulers, 2 do
255
+ local jobSchedulerId = jobSchedulers[i]
256
+ local jobSchedulerMillis = jobSchedulers[i + 1]
257
+ local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis
258
+ scheduledJobs[delayedJobId] = true
259
+ end
260
+ removeListJobs(KEYS[1], true, queueBaseKey, 0, scheduledJobs) -- wait
261
+ removeListJobs(KEYS[2], true, queueBaseKey, 0, scheduledJobs) -- paused
262
+ if ARGV[2] == "1" then
263
+ removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed
250
264
  end
251
- removeZSetJobs(KEYS[4], true, queueBaseKey, 0) -- prioritized
265
+ removeZSetJobs(KEYS[4], true, queueBaseKey, 0, scheduledJobs) -- prioritized
252
266
  `;
253
267
  exports.drain = {
254
268
  name: 'drain',
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDependencyCounts = void 0;
4
+ const content = `--[[
5
+ Get counts per child states
6
+ Input:
7
+ KEYS[1] processed key
8
+ KEYS[2] unprocessed key
9
+ KEYS[3] ignored key
10
+ KEYS[4] failed key
11
+ ARGV[1...] types
12
+ ]]
13
+ local rcall = redis.call;
14
+ local processedKey = KEYS[1]
15
+ local unprocessedKey = KEYS[2]
16
+ local ignoredKey = KEYS[3]
17
+ local failedKey = KEYS[4]
18
+ local results = {}
19
+ for i = 1, #ARGV do
20
+ if ARGV[i] == "processed" then
21
+ results[#results+1] = rcall("HLEN", processedKey)
22
+ elseif ARGV[i] == "unprocessed" then
23
+ results[#results+1] = rcall("SCARD", unprocessedKey)
24
+ elseif ARGV[i] == "ignored" then
25
+ results[#results+1] = rcall("HLEN", ignoredKey)
26
+ else
27
+ results[#results+1] = rcall("ZCARD", failedKey)
28
+ end
29
+ end
30
+ return results
31
+ `;
32
+ exports.getDependencyCounts = {
33
+ name: 'getDependencyCounts',
34
+ content,
35
+ keys: 4,
36
+ };
37
+ //# sourceMappingURL=getDependencyCounts-4.js.map
@@ -24,16 +24,16 @@ const content = `--[[
24
24
  'unknown'
25
25
  ]]
26
26
  local rcall = redis.call
27
- if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
27
+ if rcall("ZSCORE", KEYS[1], ARGV[1]) then
28
28
  return "completed"
29
29
  end
30
- if rcall("ZSCORE", KEYS[2], ARGV[1]) ~= false then
30
+ if rcall("ZSCORE", KEYS[2], ARGV[1]) then
31
31
  return "failed"
32
32
  end
33
- if rcall("ZSCORE", KEYS[3], ARGV[1]) ~= false then
33
+ if rcall("ZSCORE", KEYS[3], ARGV[1]) then
34
34
  return "delayed"
35
35
  end
36
- if rcall("ZSCORE", KEYS[8], ARGV[1]) ~= false then
36
+ if rcall("ZSCORE", KEYS[8], ARGV[1]) then
37
37
  return "prioritized"
38
38
  end
39
39
  -- Includes
@@ -60,7 +60,7 @@ local paused_items = rcall("LRANGE", KEYS[6] , 0, -1)
60
60
  if checkItemInList(paused_items, ARGV[1]) ~= nil then
61
61
  return "waiting"
62
62
  end
63
- if rcall("ZSCORE", KEYS[7], ARGV[1]) ~= false then
63
+ if rcall("ZSCORE", KEYS[7], ARGV[1]) then
64
64
  return "waiting-children"
65
65
  end
66
66
  return "unknown"
@@ -23,28 +23,28 @@ const content = `--[[
23
23
  'unknown'
24
24
  ]]
25
25
  local rcall = redis.call
26
- if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
26
+ if rcall("ZSCORE", KEYS[1], ARGV[1]) then
27
27
  return "completed"
28
28
  end
29
- if rcall("ZSCORE", KEYS[2], ARGV[1]) ~= false then
29
+ if rcall("ZSCORE", KEYS[2], ARGV[1]) then
30
30
  return "failed"
31
31
  end
32
- if rcall("ZSCORE", KEYS[3], ARGV[1]) ~= false then
32
+ if rcall("ZSCORE", KEYS[3], ARGV[1]) then
33
33
  return "delayed"
34
34
  end
35
- if rcall("ZSCORE", KEYS[8], ARGV[1]) ~= false then
35
+ if rcall("ZSCORE", KEYS[8], ARGV[1]) then
36
36
  return "prioritized"
37
37
  end
38
- if rcall("LPOS", KEYS[4] , ARGV[1]) ~= false then
38
+ if rcall("LPOS", KEYS[4] , ARGV[1]) then
39
39
  return "active"
40
40
  end
41
- if rcall("LPOS", KEYS[5] , ARGV[1]) ~= false then
41
+ if rcall("LPOS", KEYS[5] , ARGV[1]) then
42
42
  return "waiting"
43
43
  end
44
- if rcall("LPOS", KEYS[6] , ARGV[1]) ~= false then
44
+ if rcall("LPOS", KEYS[6] , ARGV[1]) then
45
45
  return "waiting"
46
46
  end
47
- if rcall("ZSCORE", KEYS[7] , ARGV[1]) ~= false then
47
+ if rcall("ZSCORE", KEYS[7] , ARGV[1]) then
48
48
  return "waiting-children"
49
49
  end
50
50
  return "unknown"
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./addDelayedJob-6"), exports);
5
- tslib_1.__exportStar(require("./addJobScheduler-2"), exports);
5
+ tslib_1.__exportStar(require("./addJobScheduler-11"), exports);
6
6
  tslib_1.__exportStar(require("./addLog-2"), exports);
7
- tslib_1.__exportStar(require("./addParentJob-4"), exports);
8
- tslib_1.__exportStar(require("./addPrioritizedJob-8"), exports);
7
+ tslib_1.__exportStar(require("./addParentJob-5"), exports);
8
+ tslib_1.__exportStar(require("./addPrioritizedJob-9"), exports);
9
9
  tslib_1.__exportStar(require("./addRepeatableJob-2"), exports);
10
- tslib_1.__exportStar(require("./addStandardJob-8"), exports);
10
+ tslib_1.__exportStar(require("./addStandardJob-9"), exports);
11
11
  tslib_1.__exportStar(require("./changeDelay-4"), exports);
12
12
  tslib_1.__exportStar(require("./changePriority-7"), exports);
13
13
  tslib_1.__exportStar(require("./cleanJobsInSet-3"), exports);
@@ -16,6 +16,7 @@ tslib_1.__exportStar(require("./extendLock-2"), exports);
16
16
  tslib_1.__exportStar(require("./extendLocks-1"), exports);
17
17
  tslib_1.__exportStar(require("./getCounts-1"), exports);
18
18
  tslib_1.__exportStar(require("./getCountsPerPriority-4"), exports);
19
+ tslib_1.__exportStar(require("./getDependencyCounts-4"), exports);
19
20
  tslib_1.__exportStar(require("./getJobScheduler-1"), exports);
20
21
  tslib_1.__exportStar(require("./getRanges-1"), exports);
21
22
  tslib_1.__exportStar(require("./getRateLimitTtl-1"), exports);
@@ -24,13 +25,13 @@ tslib_1.__exportStar(require("./getStateV2-8"), exports);
24
25
  tslib_1.__exportStar(require("./isFinished-3"), exports);
25
26
  tslib_1.__exportStar(require("./isJobInList-1"), exports);
26
27
  tslib_1.__exportStar(require("./isMaxed-2"), exports);
27
- tslib_1.__exportStar(require("./moveJobFromActiveToWait-10"), exports);
28
+ tslib_1.__exportStar(require("./moveJobFromActiveToWait-9"), exports);
28
29
  tslib_1.__exportStar(require("./moveJobsToWait-8"), exports);
29
- tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
30
+ tslib_1.__exportStar(require("./moveStalledJobsToWait-8"), exports);
30
31
  tslib_1.__exportStar(require("./moveToActive-11"), exports);
31
32
  tslib_1.__exportStar(require("./moveToDelayed-8"), exports);
32
33
  tslib_1.__exportStar(require("./moveToFinished-14"), exports);
33
- tslib_1.__exportStar(require("./moveToWaitingChildren-5"), exports);
34
+ tslib_1.__exportStar(require("./moveToWaitingChildren-8"), exports);
34
35
  tslib_1.__exportStar(require("./obliterate-2"), exports);
35
36
  tslib_1.__exportStar(require("./paginate-1"), exports);
36
37
  tslib_1.__exportStar(require("./pause-7"), exports);
@@ -40,10 +41,12 @@ tslib_1.__exportStar(require("./removeChildDependency-1"), exports);
40
41
  tslib_1.__exportStar(require("./removeJob-2"), exports);
41
42
  tslib_1.__exportStar(require("./removeJobScheduler-3"), exports);
42
43
  tslib_1.__exportStar(require("./removeRepeatable-3"), exports);
44
+ tslib_1.__exportStar(require("./removeUnprocessedChildren-2"), exports);
43
45
  tslib_1.__exportStar(require("./reprocessJob-8"), exports);
44
46
  tslib_1.__exportStar(require("./retryJob-11"), exports);
45
47
  tslib_1.__exportStar(require("./saveStacktrace-1"), exports);
46
48
  tslib_1.__exportStar(require("./updateData-1"), exports);
49
+ tslib_1.__exportStar(require("./updateJobScheduler-12"), exports);
47
50
  tslib_1.__exportStar(require("./updateProgress-3"), exports);
48
51
  tslib_1.__exportStar(require("./updateRepeatableJobMillis-1"), exports);
49
52
  //# sourceMappingURL=index.js.map
@@ -22,14 +22,14 @@ if rcall("EXISTS", KEYS[3]) ~= 1 then
22
22
  end
23
23
  return -1
24
24
  end
25
- if rcall("ZSCORE", KEYS[1], ARGV[1]) ~= false then
25
+ if rcall("ZSCORE", KEYS[1], ARGV[1]) then
26
26
  if ARGV[2] == "1" then
27
27
  local returnValue = rcall("HGET", KEYS[3], "returnvalue")
28
28
  return {1,returnValue}
29
29
  end
30
30
  return 1
31
31
  end
32
- if rcall("ZSCORE", KEYS[2], ARGV[1]) ~= false then
32
+ if rcall("ZSCORE", KEYS[2], ARGV[1]) then
33
33
  if ARGV[2] == "1" then
34
34
  local failedReason = rcall("HGET", KEYS[3], "failedReason")
35
35
  return {2,failedReason}
@@ -7,13 +7,12 @@ const content = `--[[
7
7
  KEYS[1] active key
8
8
  KEYS[2] wait key
9
9
  KEYS[3] stalled key
10
- KEYS[4] job lock key
11
- KEYS[5] paused key
12
- KEYS[6] meta key
13
- KEYS[7] limiter key
14
- KEYS[8] prioritized key
15
- KEYS[9] marker key
16
- KEYS[10] event key
10
+ KEYS[4] paused key
11
+ KEYS[5] meta key
12
+ KEYS[6] limiter key
13
+ KEYS[7] prioritized key
14
+ KEYS[8] marker key
15
+ KEYS[9] event key
17
16
  ARGV[1] job id
18
17
  ARGV[2] lock token
19
18
  ARGV[3] job id key
@@ -49,12 +48,12 @@ end
49
48
  Function to get max events value or set by default 10000.
50
49
  ]]
51
50
  local function getOrSetMaxEvents(metaKey)
52
- local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
53
- if not maxEvents then
54
- maxEvents = 10000
55
- rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
56
- end
57
- return maxEvents
51
+ local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
52
+ if not maxEvents then
53
+ maxEvents = 10000
54
+ rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
55
+ end
56
+ return maxEvents
58
57
  end
59
58
  --[[
60
59
  Function to check for the meta.paused key to decide if we are paused or not
@@ -76,35 +75,56 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
76
75
  end
77
76
  return waitKey, false
78
77
  end
79
- local jobId = ARGV[1]
80
- local token = ARGV[2]
81
- local lockKey = KEYS[4]
82
- local lockToken = rcall("GET", lockKey)
83
- local pttl = rcall("PTTL", KEYS[7])
84
- if lockToken == token then
85
- local metaKey = KEYS[6]
86
- local removed = rcall("LREM", KEYS[1], 1, jobId)
87
- if removed > 0 then
88
- local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[5])
89
- rcall("SREM", KEYS[3], jobId)
90
- local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0
91
- if priority > 0 then
92
- pushBackJobWithPriority(KEYS[8], priority, jobId)
78
+ local function removeLock(jobKey, stalledKey, token, jobId)
79
+ if token ~= "0" then
80
+ local lockKey = jobKey .. ':lock'
81
+ local lockToken = rcall("GET", lockKey)
82
+ if lockToken == token then
83
+ rcall("DEL", lockKey)
84
+ rcall("SREM", stalledKey, jobId)
93
85
  else
94
- addJobInTargetList(target, KEYS[9], "RPUSH", isPausedOrMaxed, jobId)
86
+ if lockToken then
87
+ -- Lock exists but token does not match
88
+ return -6
89
+ else
90
+ -- Lock is missing completely
91
+ return -2
92
+ end
95
93
  end
96
- rcall("DEL", lockKey)
97
- local maxEvents = getOrSetMaxEvents(metaKey)
98
- -- Emit waiting event
99
- rcall("XADD", KEYS[10], "MAXLEN", "~", maxEvents, "*", "event", "waiting",
100
- "jobId", jobId)
101
94
  end
95
+ return 0
96
+ end
97
+ local jobId = ARGV[1]
98
+ local token = ARGV[2]
99
+ local jobKey = ARGV[3]
100
+ local errorCode = removeLock(jobKey, KEYS[3], token, jobId)
101
+ if errorCode < 0 then
102
+ return errorCode
103
+ end
104
+ local metaKey = KEYS[5]
105
+ local removed = rcall("LREM", KEYS[1], 1, jobId)
106
+ if removed > 0 then
107
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[4])
108
+ local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0
109
+ if priority > 0 then
110
+ pushBackJobWithPriority(KEYS[7], priority, jobId)
111
+ else
112
+ addJobInTargetList(target, KEYS[8], "RPUSH", isPausedOrMaxed, jobId)
113
+ end
114
+ local maxEvents = getOrSetMaxEvents(metaKey)
115
+ -- Emit waiting event
116
+ rcall("XADD", KEYS[9], "MAXLEN", "~", maxEvents, "*", "event", "waiting",
117
+ "jobId", jobId, "prev", "active")
102
118
  end
103
- return pttl
104
- `;
119
+ local pttl = rcall("PTTL", KEYS[6])
120
+ if pttl > 0 then
121
+ return pttl
122
+ else
123
+ return 0
124
+ end`;
105
125
  exports.moveJobFromActiveToWait = {
106
126
  name: 'moveJobFromActiveToWait',
107
127
  content,
108
- keys: 10,
128
+ keys: 9,
109
129
  };
110
- //# sourceMappingURL=moveJobFromActiveToWait-10.js.map
130
+ //# sourceMappingURL=moveJobFromActiveToWait-9.js.map
@@ -52,12 +52,12 @@ end
52
52
  Function to get max events value or set by default 10000.
53
53
  ]]
54
54
  local function getOrSetMaxEvents(metaKey)
55
- local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
56
- if not maxEvents then
57
- maxEvents = 10000
58
- rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
59
- end
60
- return maxEvents
55
+ local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
56
+ if not maxEvents then
57
+ maxEvents = 10000
58
+ rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
59
+ end
60
+ return maxEvents
61
61
  end
62
62
  --[[
63
63
  Function to check for the meta.paused key to decide if we are paused or not
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.moveStalledJobsToWait = void 0;
4
+ const content = `--[[
5
+ Move stalled jobs to wait.
6
+ Input:
7
+ KEYS[1] 'stalled' (SET)
8
+ KEYS[2] 'wait', (LIST)
9
+ KEYS[3] 'active', (LIST)
10
+ KEYS[4] 'stalled-check', (KEY)
11
+ KEYS[5] 'meta', (KEY)
12
+ KEYS[6] 'paused', (LIST)
13
+ KEYS[7] 'marker'
14
+ KEYS[8] 'event stream' (STREAM)
15
+ ARGV[1] Max stalled job count
16
+ ARGV[2] queue.toKey('')
17
+ ARGV[3] timestamp
18
+ ARGV[4] max check time
19
+ Events:
20
+ 'stalled' with stalled job id.
21
+ ]]
22
+ local rcall = redis.call
23
+ -- Includes
24
+ --[[
25
+ Function to add job in target list and add marker if needed.
26
+ ]]
27
+ -- Includes
28
+ --[[
29
+ Add marker if needed when a job is available.
30
+ ]]
31
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
32
+ if not isPausedOrMaxed then
33
+ rcall("ZADD", markerKey, 0, "0")
34
+ end
35
+ end
36
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
37
+ rcall(pushCmd, targetKey, jobId)
38
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
39
+ end
40
+ --[[
41
+ Function to loop in batches.
42
+ Just a bit of warning, some commands as ZREM
43
+ could receive a maximum of 7000 parameters per call.
44
+ ]]
45
+ local function batches(n, batchSize)
46
+ local i = 0
47
+ return function()
48
+ local from = i * batchSize + 1
49
+ i = i + 1
50
+ if (from <= n) then
51
+ local to = math.min(from + batchSize - 1, n)
52
+ return from, to
53
+ end
54
+ end
55
+ end
56
+ --[[
57
+ Function to check for the meta.paused key to decide if we are paused or not
58
+ (since an empty list and !EXISTS are not really the same).
59
+ ]]
60
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
61
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
62
+ if queueAttributes[1] then
63
+ return pausedKey, true
64
+ else
65
+ if queueAttributes[2] then
66
+ local activeCount = rcall("LLEN", activeKey)
67
+ if activeCount >= tonumber(queueAttributes[2]) then
68
+ return waitKey, true
69
+ else
70
+ return waitKey, false
71
+ end
72
+ end
73
+ end
74
+ return waitKey, false
75
+ end
76
+ --[[
77
+ Function to trim events, default 10000.
78
+ ]]
79
+ -- Includes
80
+ --[[
81
+ Function to get max events value or set by default 10000.
82
+ ]]
83
+ local function getOrSetMaxEvents(metaKey)
84
+ local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents")
85
+ if not maxEvents then
86
+ maxEvents = 10000
87
+ rcall("HSET", metaKey, "opts.maxLenEvents", maxEvents)
88
+ end
89
+ return maxEvents
90
+ end
91
+ local function trimEvents(metaKey, eventStreamKey)
92
+ local maxEvents = getOrSetMaxEvents(metaKey)
93
+ if maxEvents then
94
+ rcall("XTRIM", eventStreamKey, "MAXLEN", "~", maxEvents)
95
+ else
96
+ rcall("XTRIM", eventStreamKey, "MAXLEN", "~", 10000)
97
+ end
98
+ end
99
+ local stalledKey = KEYS[1]
100
+ local waitKey = KEYS[2]
101
+ local activeKey = KEYS[3]
102
+ local stalledCheckKey = KEYS[4]
103
+ local metaKey = KEYS[5]
104
+ local pausedKey = KEYS[6]
105
+ local markerKey = KEYS[7]
106
+ local eventStreamKey = KEYS[8]
107
+ local maxStalledJobCount = tonumber(ARGV[1])
108
+ local queueKeyPrefix = ARGV[2]
109
+ local timestamp = ARGV[3]
110
+ local maxCheckTime = ARGV[4]
111
+ if rcall("EXISTS", stalledCheckKey) == 1 then
112
+ return {}
113
+ end
114
+ rcall("SET", stalledCheckKey, timestamp, "PX", maxCheckTime)
115
+ -- Trim events before emiting them to avoid trimming events emitted in this script
116
+ trimEvents(metaKey, eventStreamKey)
117
+ -- Move all stalled jobs to wait
118
+ local stalling = rcall('SMEMBERS', stalledKey)
119
+ local stalled = {}
120
+ if (#stalling > 0) then
121
+ rcall('DEL', stalledKey)
122
+ -- Remove from active list
123
+ for i, jobId in ipairs(stalling) do
124
+ -- Markers in waitlist DEPRECATED in v5: Remove in v6.
125
+ if string.sub(jobId, 1, 2) == "0:" then
126
+ -- If the jobId is a delay marker ID we just remove it.
127
+ rcall("LREM", activeKey, 1, jobId)
128
+ else
129
+ local jobKey = queueKeyPrefix .. jobId
130
+ -- Check that the lock is also missing, then we can handle this job as really stalled.
131
+ if (rcall("EXISTS", jobKey .. ":lock") == 0) then
132
+ -- Remove from the active queue.
133
+ local removed = rcall("LREM", activeKey, 1, jobId)
134
+ if (removed > 0) then
135
+ -- If this job has been stalled too many times, such as if it crashes the worker, then fail it.
136
+ local stalledCount = rcall("HINCRBY", jobKey, "stc", 1)
137
+ if stalledCount > maxStalledJobCount then
138
+ local jobAttributes = rcall("HMGET", jobKey, "opts", "parent")
139
+ local rawOpts = jobAttributes[1]
140
+ local rawParentData = jobAttributes[2]
141
+ local opts = cjson.decode(rawOpts)
142
+ local failedReason = "job stalled more than allowable limit"
143
+ rcall("HSET", jobKey, "defa", failedReason)
144
+ end
145
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)
146
+ -- Move the job back to the wait queue, to immediately be picked up by a waiting worker.
147
+ addJobInTargetList(target, markerKey, "RPUSH", isPausedOrMaxed, jobId)
148
+ rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId", jobId, 'prev', 'active')
149
+ -- Emit the stalled event
150
+ rcall("XADD", eventStreamKey, "*", "event", "stalled", "jobId", jobId)
151
+ table.insert(stalled, jobId)
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+ -- Mark potentially stalled jobs
158
+ local active = rcall('LRANGE', activeKey, 0, -1)
159
+ if (#active > 0) then
160
+ for from, to in batches(#active, 7000) do
161
+ rcall('SADD', stalledKey, unpack(active, from, to))
162
+ end
163
+ end
164
+ return stalled
165
+ `;
166
+ exports.moveStalledJobsToWait = {
167
+ name: 'moveStalledJobsToWait',
168
+ content,
169
+ keys: 8,
170
+ };
171
+ //# sourceMappingURL=moveStalledJobsToWait-8.js.map