bullmq 5.44.1 → 5.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/cjs/classes/async-fifo-queue.js.map +1 -1
  2. package/dist/cjs/classes/child-processor.js.map +1 -1
  3. package/dist/cjs/classes/child.js.map +1 -1
  4. package/dist/cjs/classes/flow-producer.js +15 -4
  5. package/dist/cjs/classes/flow-producer.js.map +1 -1
  6. package/dist/cjs/classes/job-scheduler.js +1 -1
  7. package/dist/cjs/classes/job-scheduler.js.map +1 -1
  8. package/dist/cjs/classes/job.js +137 -54
  9. package/dist/cjs/classes/job.js.map +1 -1
  10. package/dist/cjs/classes/queue-base.js +1 -4
  11. package/dist/cjs/classes/queue-base.js.map +1 -1
  12. package/dist/cjs/classes/queue-events-producer.js.map +1 -1
  13. package/dist/cjs/classes/queue-events.js.map +1 -1
  14. package/dist/cjs/classes/queue-getters.js +12 -15
  15. package/dist/cjs/classes/queue-getters.js.map +1 -1
  16. package/dist/cjs/classes/queue-keys.js.map +1 -1
  17. package/dist/cjs/classes/queue.js +12 -13
  18. package/dist/cjs/classes/queue.js.map +1 -1
  19. package/dist/cjs/classes/redis-connection.js +1 -1
  20. package/dist/cjs/classes/redis-connection.js.map +1 -1
  21. package/dist/cjs/classes/repeat.js +1 -1
  22. package/dist/cjs/classes/repeat.js.map +1 -1
  23. package/dist/cjs/classes/scripts.js +18 -7
  24. package/dist/cjs/classes/scripts.js.map +1 -1
  25. package/dist/cjs/classes/worker.js +4 -0
  26. package/dist/cjs/classes/worker.js.map +1 -1
  27. package/dist/cjs/commands/addJobScheduler-11.lua +52 -33
  28. package/dist/cjs/commands/includes/deduplicateJob.lua +16 -17
  29. package/dist/cjs/commands/includes/isLocked.lua +1 -0
  30. package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +79 -0
  31. package/dist/cjs/commands/includes/moveParentToWait.lua +48 -0
  32. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  33. package/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  34. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  35. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  36. package/dist/cjs/commands/includes/removeJob.lua +2 -2
  37. package/dist/cjs/commands/includes/removeJobWithChildren.lua +94 -0
  38. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +5 -5
  39. package/dist/cjs/commands/includes/storeJob.lua +1 -1
  40. package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  41. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +18 -53
  42. package/dist/cjs/commands/moveToFinished-14.lua +43 -51
  43. package/dist/cjs/commands/moveToWaitingChildren-8.lua +5 -32
  44. package/dist/cjs/commands/removeJob-3.lua +14 -72
  45. package/dist/cjs/commands/removeUnprocessedChildren-2.lua +31 -0
  46. package/dist/cjs/commands/updateJobScheduler-12.lua +29 -23
  47. package/dist/cjs/scripts/addDelayedJob-6.js +73 -55
  48. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  49. package/dist/cjs/scripts/addJobScheduler-11.js +59 -40
  50. package/dist/cjs/scripts/addJobScheduler-11.js.map +1 -1
  51. package/dist/cjs/scripts/addParentJob-4.js +73 -55
  52. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  53. package/dist/cjs/scripts/addPrioritizedJob-8.js +73 -55
  54. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
  55. package/dist/cjs/scripts/addRepeatableJob-2.js +14 -9
  56. package/dist/cjs/scripts/addRepeatableJob-2.js.map +1 -1
  57. package/dist/cjs/scripts/addStandardJob-8.js +73 -55
  58. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
  59. package/dist/cjs/scripts/cleanJobsInSet-3.js +14 -9
  60. package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
  61. package/dist/cjs/scripts/drain-5.js +14 -9
  62. package/dist/cjs/scripts/drain-5.js.map +1 -1
  63. package/dist/cjs/scripts/index.js +1 -0
  64. package/dist/cjs/scripts/index.js.map +1 -1
  65. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +157 -155
  66. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  67. package/dist/cjs/scripts/moveToFinished-14.js +183 -157
  68. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  69. package/dist/cjs/scripts/moveToWaitingChildren-8.js +145 -137
  70. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
  71. package/dist/cjs/scripts/obliterate-2.js +14 -9
  72. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  73. package/dist/cjs/scripts/removeChildDependency-1.js +5 -5
  74. package/dist/cjs/scripts/removeJob-3.js +97 -63
  75. package/dist/cjs/scripts/removeJob-3.js.map +1 -1
  76. package/dist/cjs/scripts/removeUnprocessedChildren-2.js +338 -0
  77. package/dist/cjs/scripts/removeUnprocessedChildren-2.js.map +1 -0
  78. package/dist/cjs/scripts/updateJobScheduler-12.js +27 -21
  79. package/dist/cjs/scripts/updateJobScheduler-12.js.map +1 -1
  80. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  81. package/dist/cjs/types/index.js +1 -0
  82. package/dist/cjs/types/index.js.map +1 -1
  83. package/dist/cjs/types/job-progress.js +3 -0
  84. package/dist/cjs/types/job-progress.js.map +1 -0
  85. package/dist/cjs/utils.js +12 -1
  86. package/dist/cjs/utils.js.map +1 -1
  87. package/dist/cjs/version.js +1 -1
  88. package/dist/esm/classes/async-fifo-queue.js.map +1 -1
  89. package/dist/esm/classes/child-processor.js.map +1 -1
  90. package/dist/esm/classes/child.js.map +1 -1
  91. package/dist/esm/classes/flow-producer.js +15 -4
  92. package/dist/esm/classes/flow-producer.js.map +1 -1
  93. package/dist/esm/classes/job-scheduler.js +1 -1
  94. package/dist/esm/classes/job-scheduler.js.map +1 -1
  95. package/dist/esm/classes/job.d.ts +49 -14
  96. package/dist/esm/classes/job.js +138 -55
  97. package/dist/esm/classes/job.js.map +1 -1
  98. package/dist/esm/classes/queue-base.d.ts +1 -4
  99. package/dist/esm/classes/queue-base.js +1 -4
  100. package/dist/esm/classes/queue-base.js.map +1 -1
  101. package/dist/esm/classes/queue-events-producer.d.ts +2 -2
  102. package/dist/esm/classes/queue-events-producer.js.map +1 -1
  103. package/dist/esm/classes/queue-events.d.ts +118 -29
  104. package/dist/esm/classes/queue-events.js.map +1 -1
  105. package/dist/esm/classes/queue-getters.d.ts +11 -14
  106. package/dist/esm/classes/queue-getters.js +12 -15
  107. package/dist/esm/classes/queue-getters.js.map +1 -1
  108. package/dist/esm/classes/queue-keys.js.map +1 -1
  109. package/dist/esm/classes/queue.d.ts +14 -15
  110. package/dist/esm/classes/queue.js +12 -13
  111. package/dist/esm/classes/queue.js.map +1 -1
  112. package/dist/esm/classes/redis-connection.js +1 -1
  113. package/dist/esm/classes/redis-connection.js.map +1 -1
  114. package/dist/esm/classes/repeat.js +1 -1
  115. package/dist/esm/classes/repeat.js.map +1 -1
  116. package/dist/esm/classes/scripts.d.ts +4 -3
  117. package/dist/esm/classes/scripts.js +18 -7
  118. package/dist/esm/classes/scripts.js.map +1 -1
  119. package/dist/esm/classes/worker.d.ts +2 -1
  120. package/dist/esm/classes/worker.js +5 -1
  121. package/dist/esm/classes/worker.js.map +1 -1
  122. package/dist/esm/commands/addJobScheduler-11.lua +52 -33
  123. package/dist/esm/commands/includes/deduplicateJob.lua +16 -17
  124. package/dist/esm/commands/includes/isLocked.lua +1 -0
  125. package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +79 -0
  126. package/dist/esm/commands/includes/moveParentToWait.lua +48 -0
  127. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +9 -50
  128. package/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  129. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnFinalization.lua +23 -0
  130. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeededOnRemoval.lua +16 -0
  131. package/dist/esm/commands/includes/removeJob.lua +2 -2
  132. package/dist/esm/commands/includes/removeJobWithChildren.lua +94 -0
  133. package/dist/esm/commands/includes/removeParentDependencyKey.lua +5 -5
  134. package/dist/esm/commands/includes/storeJob.lua +1 -1
  135. package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  136. package/dist/esm/commands/moveStalledJobsToWait-9.lua +18 -53
  137. package/dist/esm/commands/moveToFinished-14.lua +43 -51
  138. package/dist/esm/commands/moveToWaitingChildren-8.lua +5 -32
  139. package/dist/esm/commands/removeJob-3.lua +14 -72
  140. package/dist/esm/commands/removeUnprocessedChildren-2.lua +31 -0
  141. package/dist/esm/commands/updateJobScheduler-12.lua +29 -23
  142. package/dist/esm/interfaces/job-json.d.ts +5 -2
  143. package/dist/esm/interfaces/minimal-job.d.ts +29 -11
  144. package/dist/esm/interfaces/queue-options.d.ts +6 -2
  145. package/dist/esm/interfaces/repeat-options.d.ts +1 -1
  146. package/dist/esm/interfaces/sandboxed-job.d.ts +2 -2
  147. package/dist/esm/interfaces/sandboxed-options.d.ts +1 -1
  148. package/dist/esm/interfaces/telemetry.d.ts +18 -15
  149. package/dist/esm/interfaces/worker-options.d.ts +10 -10
  150. package/dist/esm/scripts/addDelayedJob-6.js +73 -55
  151. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  152. package/dist/esm/scripts/addJobScheduler-11.js +59 -40
  153. package/dist/esm/scripts/addJobScheduler-11.js.map +1 -1
  154. package/dist/esm/scripts/addParentJob-4.js +73 -55
  155. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  156. package/dist/esm/scripts/addPrioritizedJob-8.js +73 -55
  157. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
  158. package/dist/esm/scripts/addRepeatableJob-2.js +14 -9
  159. package/dist/esm/scripts/addRepeatableJob-2.js.map +1 -1
  160. package/dist/esm/scripts/addStandardJob-8.js +73 -55
  161. package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
  162. package/dist/esm/scripts/cleanJobsInSet-3.js +14 -9
  163. package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
  164. package/dist/esm/scripts/drain-5.js +14 -9
  165. package/dist/esm/scripts/drain-5.js.map +1 -1
  166. package/dist/esm/scripts/index.d.ts +1 -0
  167. package/dist/esm/scripts/index.js +1 -0
  168. package/dist/esm/scripts/index.js.map +1 -1
  169. package/dist/esm/scripts/moveStalledJobsToWait-9.js +157 -155
  170. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  171. package/dist/esm/scripts/moveToFinished-14.js +183 -157
  172. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  173. package/dist/esm/scripts/moveToWaitingChildren-8.js +145 -137
  174. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
  175. package/dist/esm/scripts/obliterate-2.js +14 -9
  176. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  177. package/dist/esm/scripts/removeChildDependency-1.js +5 -5
  178. package/dist/esm/scripts/removeJob-3.js +97 -63
  179. package/dist/esm/scripts/removeJob-3.js.map +1 -1
  180. package/dist/esm/scripts/removeUnprocessedChildren-2.d.ts +5 -0
  181. package/dist/esm/scripts/removeUnprocessedChildren-2.js +335 -0
  182. package/dist/esm/scripts/removeUnprocessedChildren-2.js.map +1 -0
  183. package/dist/esm/scripts/updateJobScheduler-12.js +27 -21
  184. package/dist/esm/scripts/updateJobScheduler-12.js.map +1 -1
  185. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  186. package/dist/esm/types/index.d.ts +1 -0
  187. package/dist/esm/types/index.js +1 -0
  188. package/dist/esm/types/index.js.map +1 -1
  189. package/dist/esm/types/job-options.d.ts +13 -2
  190. package/dist/esm/types/job-progress.d.ts +1 -0
  191. package/dist/esm/types/job-progress.js +2 -0
  192. package/dist/esm/types/job-progress.js.map +1 -0
  193. package/dist/esm/utils.d.ts +17 -0
  194. package/dist/esm/utils.js +11 -0
  195. package/dist/esm/utils.js.map +1 -1
  196. package/dist/esm/version.d.ts +1 -1
  197. package/dist/esm/version.js +1 -1
  198. package/package.json +26 -21
  199. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -80
  200. package/dist/cjs/commands/includes/removeDeduplicationKey.lua +0 -11
  201. package/dist/cjs/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
  202. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +0 -80
  203. package/dist/esm/commands/includes/removeDeduplicationKey.lua +0 -11
  204. package/dist/esm/commands/includes/removeDeduplicationKeyIfNeeded.lua +0 -14
@@ -75,25 +75,25 @@ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, pr
75
75
  end
76
76
  --[[
77
77
  Function to debounce a job.
78
- ]]
78
+ ]]
79
79
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
80
80
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
81
81
  if deduplicationId then
82
- local ttl = deduplicationOpts['ttl']
83
- local deduplicationKeyExists
84
- if ttl then
85
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
86
- else
87
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
88
- end
89
- if deduplicationKeyExists then
90
- local currentDebounceJobId = rcall('GET', deduplicationKey)
91
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
92
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
93
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
94
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
95
- return currentDebounceJobId
96
- end
82
+ local ttl = deduplicationOpts['ttl']
83
+ local deduplicationKeyExists
84
+ if ttl then
85
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
86
+ else
87
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
88
+ end
89
+ if deduplicationKeyExists then
90
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
91
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
92
+ "debounceId", deduplicationId)
93
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
94
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
95
+ return currentDebounceJobId
96
+ end
97
97
  end
98
98
  end
99
99
  --[[
@@ -112,7 +112,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
112
112
  table.insert(optionalValues, "parent")
113
113
  table.insert(optionalValues, parentData)
114
114
  end
115
- if repeatJobKey ~= nil then
115
+ if repeatJobKey then
116
116
  table.insert(optionalValues, "rjk")
117
117
  table.insert(optionalValues, repeatJobKey)
118
118
  end
@@ -153,7 +153,16 @@ end
153
153
  ]]
154
154
  -- Includes
155
155
  --[[
156
- Validate and move parent to active if needed.
156
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
157
+ if no pending dependencies.
158
+ ]]
159
+ -- Includes
160
+ --[[
161
+ Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
162
+ ]]
163
+ -- Includes
164
+ --[[
165
+ Move parent to a wait status (wait, prioritized or delayed)
157
166
  ]]
158
167
  -- Includes
159
168
  --[[
@@ -224,51 +233,60 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
224
233
  end
225
234
  return waitKey, false
226
235
  end
227
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
228
- parentKey, parentId, timestamp)
229
- local isParentActive = rcall("ZSCORE",
230
- parentQueueKey .. ":waiting-children", parentId)
231
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
232
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
233
- local parentWaitKey = parentQueueKey .. ":wait"
234
- local parentPausedKey = parentQueueKey .. ":paused"
235
- local parentActiveKey = parentQueueKey .. ":active"
236
- local parentMetaKey = parentQueueKey .. ":meta"
237
- local parentMarkerKey = parentQueueKey .. ":marker"
238
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
239
- local priority = tonumber(jobAttributes[1]) or 0
240
- local delay = tonumber(jobAttributes[2]) or 0
241
- if delay > 0 then
242
- local delayedTimestamp = tonumber(timestamp) + delay
243
- local score = delayedTimestamp * 0x1000
244
- local parentDelayedKey = parentQueueKey .. ":delayed"
245
- rcall("ZADD", parentDelayedKey, score, parentId)
246
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
247
- "jobId", parentId, "delay", delayedTimestamp)
248
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
236
+ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
237
+ local parentWaitKey = parentQueueKey .. ":wait"
238
+ local parentPausedKey = parentQueueKey .. ":paused"
239
+ local parentActiveKey = parentQueueKey .. ":active"
240
+ local parentMetaKey = parentQueueKey .. ":meta"
241
+ local parentMarkerKey = parentQueueKey .. ":marker"
242
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
243
+ local priority = tonumber(jobAttributes[1]) or 0
244
+ local delay = tonumber(jobAttributes[2]) or 0
245
+ -- ignore dependencies if any left
246
+ rcall("HSET", parentKey, "igdp", 1)
247
+ if delay > 0 then
248
+ local delayedTimestamp = tonumber(timestamp) + delay
249
+ local score = delayedTimestamp * 0x1000
250
+ local parentDelayedKey = parentQueueKey .. ":delayed"
251
+ rcall("ZADD", parentDelayedKey, score, parentId)
252
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
253
+ delayedTimestamp)
254
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
255
+ else
256
+ if priority == 0 then
257
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
258
+ parentWaitKey, parentPausedKey)
259
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
249
260
  else
250
- if priority == 0 then
251
- local parentTarget, isParentPausedOrMaxed =
252
- getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
253
- parentPausedKey)
254
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
255
- parentId)
256
- else
257
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
258
- addJobWithPriority(parentMarkerKey,
259
- parentQueueKey .. ":prioritized", priority,
260
- parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
261
- end
262
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
263
- "jobId", parentId, "prev", "waiting-children")
261
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
262
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
263
+ parentQueueKey .. ":pc", isPausedOrMaxed)
264
264
  end
265
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
266
+ "waiting-children")
265
267
  end
266
268
  end
269
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
270
+ if rcall("EXISTS", parentKey) == 1 then
271
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
272
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
273
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
274
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
275
+ end
276
+ end
277
+ end
278
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
279
+ parentId, timestamp)
280
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
281
+ if doNotHavePendingDependencies then
282
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
283
+ end
284
+ end
267
285
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
268
286
  parentId, jobIdKey, returnvalue, timestamp )
269
287
  local processedSet = parentKey .. ":processed"
270
288
  rcall("HSET", processedSet, jobIdKey, returnvalue)
271
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
289
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
272
290
  end
273
291
  local function updateExistingJobsParent(parentKey, parent, parentData,
274
292
  parentDependenciesKey, completedKey,
@@ -1 +1 @@
1
- {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Vf,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Wf,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -29,13 +29,18 @@ local prefixKey = ARGV[5]
29
29
  ]]
30
30
  -- Includes
31
31
  --[[
32
- Function to remove deduplication key.
32
+ Function to remove deduplication key if needed
33
+ when a job is being removed.
33
34
  ]]
34
- local function removeDeduplicationKey(prefixKey, jobKey)
35
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
36
+ jobKey, jobId)
35
37
  local deduplicationId = rcall("HGET", jobKey, "deid")
36
38
  if deduplicationId then
37
39
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
38
- rcall("DEL", deduplicationKey)
40
+ local currentJobId = rcall('GET', deduplicationKey)
41
+ if currentJobId and currentJobId == jobId then
42
+ return rcall("DEL", deduplicationKey)
43
+ end
39
44
  end
40
45
  end
41
46
  --[[
@@ -97,7 +102,7 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
97
102
  end
98
103
  return waitKey, false
99
104
  end
100
- local function moveParentToWait(parentPrefix, parentId, emitEvent)
105
+ local function _moveParentToWait(parentPrefix, parentId, emitEvent)
101
106
  local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
102
107
  parentPrefix .. "wait", parentPrefix .. "paused")
103
108
  addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
@@ -125,10 +130,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
125
130
  rcall("DEL", parentPrefix .. "de:" .. debounceId)
126
131
  end
127
132
  else
128
- moveParentToWait(parentPrefix, parentId)
133
+ _moveParentToWait(parentPrefix, parentId)
129
134
  end
130
135
  else
131
- moveParentToWait(parentPrefix, parentId, true)
136
+ _moveParentToWait(parentPrefix, parentId, true)
132
137
  end
133
138
  end
134
139
  end
@@ -156,10 +161,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
156
161
  rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
157
162
  end
158
163
  else
159
- moveParentToWait(parentPrefix, parentId)
164
+ _moveParentToWait(parentPrefix, parentId)
160
165
  end
161
166
  else
162
- moveParentToWait(parentPrefix, parentId, true)
167
+ _moveParentToWait(parentPrefix, parentId, true)
163
168
  end
164
169
  end
165
170
  end
@@ -173,7 +178,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
173
178
  local jobKey = baseKey .. jobId
174
179
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
175
180
  if shouldRemoveDeduplicationKey then
176
- removeDeduplicationKey(baseKey, jobKey)
181
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
177
182
  end
178
183
  removeJobKeys(jobKey)
179
184
  end
@@ -1 +1 @@
1
- {"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Nf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -69,25 +69,25 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
69
69
  end
70
70
  --[[
71
71
  Function to debounce a job.
72
- ]]
72
+ ]]
73
73
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
74
74
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
75
75
  if deduplicationId then
76
- local ttl = deduplicationOpts['ttl']
77
- local deduplicationKeyExists
78
- if ttl then
79
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
80
- else
81
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
82
- end
83
- if deduplicationKeyExists then
84
- local currentDebounceJobId = rcall('GET', deduplicationKey)
85
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
86
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
87
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
88
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
89
- return currentDebounceJobId
90
- end
76
+ local ttl = deduplicationOpts['ttl']
77
+ local deduplicationKeyExists
78
+ if ttl then
79
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
80
+ else
81
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
82
+ end
83
+ if deduplicationKeyExists then
84
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
85
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
86
+ "debounceId", deduplicationId)
87
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
88
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
89
+ return currentDebounceJobId
90
+ end
91
91
  end
92
92
  end
93
93
  --[[
@@ -137,7 +137,16 @@ end
137
137
  ]]
138
138
  -- Includes
139
139
  --[[
140
- Validate and move parent to active if needed.
140
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
141
+ if no pending dependencies.
142
+ ]]
143
+ -- Includes
144
+ --[[
145
+ Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
146
+ ]]
147
+ -- Includes
148
+ --[[
149
+ Move parent to a wait status (wait, prioritized or delayed)
141
150
  ]]
142
151
  -- Includes
143
152
  --[[
@@ -197,51 +206,60 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
197
206
  end
198
207
  return false
199
208
  end
200
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
201
- parentKey, parentId, timestamp)
202
- local isParentActive = rcall("ZSCORE",
203
- parentQueueKey .. ":waiting-children", parentId)
204
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
205
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
206
- local parentWaitKey = parentQueueKey .. ":wait"
207
- local parentPausedKey = parentQueueKey .. ":paused"
208
- local parentActiveKey = parentQueueKey .. ":active"
209
- local parentMetaKey = parentQueueKey .. ":meta"
210
- local parentMarkerKey = parentQueueKey .. ":marker"
211
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
212
- local priority = tonumber(jobAttributes[1]) or 0
213
- local delay = tonumber(jobAttributes[2]) or 0
214
- if delay > 0 then
215
- local delayedTimestamp = tonumber(timestamp) + delay
216
- local score = delayedTimestamp * 0x1000
217
- local parentDelayedKey = parentQueueKey .. ":delayed"
218
- rcall("ZADD", parentDelayedKey, score, parentId)
219
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
220
- "jobId", parentId, "delay", delayedTimestamp)
221
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
209
+ local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
210
+ local parentWaitKey = parentQueueKey .. ":wait"
211
+ local parentPausedKey = parentQueueKey .. ":paused"
212
+ local parentActiveKey = parentQueueKey .. ":active"
213
+ local parentMetaKey = parentQueueKey .. ":meta"
214
+ local parentMarkerKey = parentQueueKey .. ":marker"
215
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
216
+ local priority = tonumber(jobAttributes[1]) or 0
217
+ local delay = tonumber(jobAttributes[2]) or 0
218
+ -- ignore dependencies if any left
219
+ rcall("HSET", parentKey, "igdp", 1)
220
+ if delay > 0 then
221
+ local delayedTimestamp = tonumber(timestamp) + delay
222
+ local score = delayedTimestamp * 0x1000
223
+ local parentDelayedKey = parentQueueKey .. ":delayed"
224
+ rcall("ZADD", parentDelayedKey, score, parentId)
225
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
226
+ delayedTimestamp)
227
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
228
+ else
229
+ if priority == 0 then
230
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
231
+ parentWaitKey, parentPausedKey)
232
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
222
233
  else
223
- if priority == 0 then
224
- local parentTarget, isParentPausedOrMaxed =
225
- getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
226
- parentPausedKey)
227
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
228
- parentId)
229
- else
230
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
231
- addJobWithPriority(parentMarkerKey,
232
- parentQueueKey .. ":prioritized", priority,
233
- parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
234
- end
235
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
236
- "jobId", parentId, "prev", "waiting-children")
234
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
235
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
236
+ parentQueueKey .. ":pc", isPausedOrMaxed)
237
237
  end
238
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
239
+ "waiting-children")
238
240
  end
239
241
  end
242
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
243
+ if rcall("EXISTS", parentKey) == 1 then
244
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
245
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
246
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
247
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
248
+ end
249
+ end
250
+ end
251
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
252
+ parentId, timestamp)
253
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
254
+ if doNotHavePendingDependencies then
255
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
256
+ end
257
+ end
240
258
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
241
259
  parentId, jobIdKey, returnvalue, timestamp )
242
260
  local processedSet = parentKey .. ":processed"
243
261
  rcall("HSET", processedSet, jobIdKey, returnvalue)
244
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
262
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
245
263
  end
246
264
  local function updateExistingJobsParent(parentKey, parent, parentData,
247
265
  parentDependenciesKey, completedKey,
@@ -293,7 +311,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
293
311
  table.insert(optionalValues, "parent")
294
312
  table.insert(optionalValues, parentData)
295
313
  end
296
- if repeatJobKey ~= nil then
314
+ if repeatJobKey then
297
315
  table.insert(optionalValues, "rjk")
298
316
  table.insert(optionalValues, repeatJobKey)
299
317
  end
@@ -1 +1 @@
1
- {"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Vf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgXf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -65,13 +65,18 @@ end
65
65
  ]]
66
66
  -- Includes
67
67
  --[[
68
- Function to remove deduplication key.
68
+ Function to remove deduplication key if needed
69
+ when a job is being removed.
69
70
  ]]
70
- local function removeDeduplicationKey(prefixKey, jobKey)
71
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
72
+ jobKey, jobId)
71
73
  local deduplicationId = rcall("HGET", jobKey, "deid")
72
74
  if deduplicationId then
73
75
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
74
- rcall("DEL", deduplicationKey)
76
+ local currentJobId = rcall('GET', deduplicationKey)
77
+ if currentJobId and currentJobId == jobId then
78
+ return rcall("DEL", deduplicationKey)
79
+ end
75
80
  end
76
81
  end
77
82
  --[[
@@ -133,7 +138,7 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
133
138
  end
134
139
  return waitKey, false
135
140
  end
136
- local function moveParentToWait(parentPrefix, parentId, emitEvent)
141
+ local function _moveParentToWait(parentPrefix, parentId, emitEvent)
137
142
  local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
138
143
  parentPrefix .. "wait", parentPrefix .. "paused")
139
144
  addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
@@ -161,10 +166,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
161
166
  rcall("DEL", parentPrefix .. "de:" .. debounceId)
162
167
  end
163
168
  else
164
- moveParentToWait(parentPrefix, parentId)
169
+ _moveParentToWait(parentPrefix, parentId)
165
170
  end
166
171
  else
167
- moveParentToWait(parentPrefix, parentId, true)
172
+ _moveParentToWait(parentPrefix, parentId, true)
168
173
  end
169
174
  end
170
175
  end
@@ -192,10 +197,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
192
197
  rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
193
198
  end
194
199
  else
195
- moveParentToWait(parentPrefix, parentId)
200
+ _moveParentToWait(parentPrefix, parentId)
196
201
  end
197
202
  else
198
- moveParentToWait(parentPrefix, parentId, true)
203
+ _moveParentToWait(parentPrefix, parentId, true)
199
204
  end
200
205
  end
201
206
  end
@@ -209,7 +214,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
209
214
  local jobKey = baseKey .. jobId
210
215
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
211
216
  if shouldRemoveDeduplicationKey then
212
- removeDeduplicationKey(baseKey, jobKey)
217
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
213
218
  end
214
219
  removeJobKeys(jobKey)
215
220
  end
@@ -1 +1 @@
1
- {"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cle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IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -37,13 +37,18 @@ end
37
37
  ]]
38
38
  -- Includes
39
39
  --[[
40
- Function to remove deduplication key.
40
+ Function to remove deduplication key if needed
41
+ when a job is being removed.
41
42
  ]]
42
- local function removeDeduplicationKey(prefixKey, jobKey)
43
+ local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
44
+ jobKey, jobId)
43
45
  local deduplicationId = rcall("HGET", jobKey, "deid")
44
46
  if deduplicationId then
45
47
  local deduplicationKey = prefixKey .. "de:" .. deduplicationId
46
- rcall("DEL", deduplicationKey)
48
+ local currentJobId = rcall('GET', deduplicationKey)
49
+ if currentJobId and currentJobId == jobId then
50
+ return rcall("DEL", deduplicationKey)
51
+ end
47
52
  end
48
53
  end
49
54
  --[[
@@ -105,7 +110,7 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
105
110
  end
106
111
  return waitKey, false
107
112
  end
108
- local function moveParentToWait(parentPrefix, parentId, emitEvent)
113
+ local function _moveParentToWait(parentPrefix, parentId, emitEvent)
109
114
  local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
110
115
  parentPrefix .. "wait", parentPrefix .. "paused")
111
116
  addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
@@ -133,10 +138,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
133
138
  rcall("DEL", parentPrefix .. "de:" .. debounceId)
134
139
  end
135
140
  else
136
- moveParentToWait(parentPrefix, parentId)
141
+ _moveParentToWait(parentPrefix, parentId)
137
142
  end
138
143
  else
139
- moveParentToWait(parentPrefix, parentId, true)
144
+ _moveParentToWait(parentPrefix, parentId, true)
140
145
  end
141
146
  end
142
147
  end
@@ -164,10 +169,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
164
169
  rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
165
170
  end
166
171
  else
167
- moveParentToWait(parentPrefix, parentId)
172
+ _moveParentToWait(parentPrefix, parentId)
168
173
  end
169
174
  else
170
- moveParentToWait(parentPrefix, parentId, true)
175
+ _moveParentToWait(parentPrefix, parentId, true)
171
176
  end
172
177
  end
173
178
  end
@@ -181,7 +186,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
181
186
  local jobKey = baseKey .. jobId
182
187
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
183
188
  if shouldRemoveDeduplicationKey then
184
- removeDeduplicationKey(baseKey, jobKey)
189
+ removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
185
190
  end
186
191
  removeJobKeys(jobKey)
187
192
  end
@@ -1 +1 @@
1
- {"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiQf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsQf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -38,6 +38,7 @@ export * from './removeChildDependency-1';
38
38
  export * from './removeJob-3';
39
39
  export * from './removeJobScheduler-3';
40
40
  export * from './removeRepeatable-3';
41
+ export * from './removeUnprocessedChildren-2';
41
42
  export * from './reprocessJob-8';
42
43
  export * from './retryJob-11';
43
44
  export * from './saveStacktrace-1';
@@ -38,6 +38,7 @@ export * from './removeChildDependency-1';
38
38
  export * from './removeJob-3';
39
39
  export * from './removeJobScheduler-3';
40
40
  export * from './removeRepeatable-3';
41
+ export * from './removeUnprocessedChildren-2';
41
42
  export * from './reprocessJob-8';
42
43
  export * from './retryJob-11';
43
44
  export * from './saveStacktrace-1';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe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