bullmq 5.49.1 → 5.49.2

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 (60) hide show
  1. package/dist/cjs/classes/job.js +3 -0
  2. package/dist/cjs/classes/job.js.map +1 -1
  3. package/dist/cjs/classes/worker.js +4 -0
  4. package/dist/cjs/classes/worker.js.map +1 -1
  5. package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +15 -31
  6. package/dist/cjs/commands/includes/moveParentToWait.lua +32 -33
  7. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -4
  8. package/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  9. package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  10. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +0 -2
  11. package/dist/cjs/commands/moveToFinished-14.lua +5 -3
  12. package/dist/cjs/commands/moveToWaitingChildren-8.lua +0 -2
  13. package/dist/cjs/scripts/addDelayedJob-6.js +51 -37
  14. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  15. package/dist/cjs/scripts/addParentJob-4.js +51 -37
  16. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  17. package/dist/cjs/scripts/addPrioritizedJob-8.js +51 -37
  18. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
  19. package/dist/cjs/scripts/addStandardJob-8.js +51 -37
  20. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
  21. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +64 -61
  22. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  23. package/dist/cjs/scripts/moveToFinished-14.js +69 -63
  24. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  25. package/dist/cjs/scripts/moveToWaitingChildren-8.js +64 -61
  26. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
  27. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  28. package/dist/cjs/version.js +1 -1
  29. package/dist/esm/classes/job.d.ts +5 -0
  30. package/dist/esm/classes/job.js +3 -0
  31. package/dist/esm/classes/job.js.map +1 -1
  32. package/dist/esm/classes/worker.js +5 -1
  33. package/dist/esm/classes/worker.js.map +1 -1
  34. package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +15 -31
  35. package/dist/esm/commands/includes/moveParentToWait.lua +32 -33
  36. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -4
  37. package/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
  38. package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
  39. package/dist/esm/commands/moveStalledJobsToWait-9.lua +0 -2
  40. package/dist/esm/commands/moveToFinished-14.lua +5 -3
  41. package/dist/esm/commands/moveToWaitingChildren-8.lua +0 -2
  42. package/dist/esm/interfaces/job-json.d.ts +1 -0
  43. package/dist/esm/scripts/addDelayedJob-6.js +51 -37
  44. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  45. package/dist/esm/scripts/addParentJob-4.js +51 -37
  46. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  47. package/dist/esm/scripts/addPrioritizedJob-8.js +51 -37
  48. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
  49. package/dist/esm/scripts/addStandardJob-8.js +51 -37
  50. package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
  51. package/dist/esm/scripts/moveStalledJobsToWait-9.js +64 -61
  52. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  53. package/dist/esm/scripts/moveToFinished-14.js +69 -63
  54. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  55. package/dist/esm/scripts/moveToWaitingChildren-8.js +64 -61
  56. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
  57. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  58. package/dist/esm/version.d.ts +1 -1
  59. package/dist/esm/version.js +1 -1
  60. package/package.json +1 -1
@@ -161,12 +161,19 @@ end
161
161
  Validate and move or add dependencies to parent.
162
162
  ]]
163
163
  -- Includes
164
+ --[[
165
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
166
+ if no pending dependencies.
167
+ ]]
168
+ -- Includes
164
169
  --[[
165
170
  Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
166
171
  ]]
172
+ -- Includes
167
173
  --[[
168
- Validate and move parent to a wait status (wait, prioritized or delayed)
174
+ Move parent to a wait status (wait, prioritized or delayed)
169
175
  ]]
176
+ -- Includes
170
177
  --[[
171
178
  Function to add job in target list and add marker if needed.
172
179
  ]]
@@ -237,52 +244,59 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
237
244
  return waitKey, false
238
245
  end
239
246
  local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
240
- local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
241
- if isParentWaitingChildren > 0 then
242
- local parentWaitKey = parentQueueKey .. ":wait"
243
- local parentPausedKey = parentQueueKey .. ":paused"
244
- local parentActiveKey = parentQueueKey .. ":active"
245
- local parentMetaKey = parentQueueKey .. ":meta"
246
- local parentMarkerKey = parentQueueKey .. ":marker"
247
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
248
- local priority = tonumber(jobAttributes[1]) or 0
249
- local delay = tonumber(jobAttributes[2]) or 0
250
- -- ignore dependencies if any left
251
- rcall("HSET", parentKey, "igdp", 1)
252
- if delay > 0 then
253
- local delayedTimestamp = tonumber(timestamp) + delay
254
- local score = delayedTimestamp * 0x1000
255
- local parentDelayedKey = parentQueueKey .. ":delayed"
256
- rcall("ZADD", parentDelayedKey, score, parentId)
257
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
258
- delayedTimestamp)
259
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
247
+ local parentWaitKey = parentQueueKey .. ":wait"
248
+ local parentPausedKey = parentQueueKey .. ":paused"
249
+ local parentActiveKey = parentQueueKey .. ":active"
250
+ local parentMetaKey = parentQueueKey .. ":meta"
251
+ local parentMarkerKey = parentQueueKey .. ":marker"
252
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
253
+ local priority = tonumber(jobAttributes[1]) or 0
254
+ local delay = tonumber(jobAttributes[2]) or 0
255
+ -- ignore dependencies if any left
256
+ rcall("HSET", parentKey, "igdp", 1)
257
+ if delay > 0 then
258
+ local delayedTimestamp = tonumber(timestamp) + delay
259
+ local score = delayedTimestamp * 0x1000
260
+ local parentDelayedKey = parentQueueKey .. ":delayed"
261
+ rcall("ZADD", parentDelayedKey, score, parentId)
262
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
263
+ delayedTimestamp)
264
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
265
+ else
266
+ if priority == 0 then
267
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
268
+ parentWaitKey, parentPausedKey)
269
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
260
270
  else
261
- if priority == 0 then
262
- local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
263
- parentWaitKey, parentPausedKey)
264
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
265
- else
266
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
267
- addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
268
- parentQueueKey .. ":pc", isPausedOrMaxed)
269
- end
270
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
271
- "waiting-children")
271
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
272
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
273
+ parentQueueKey .. ":pc", isPausedOrMaxed)
272
274
  end
275
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
276
+ "waiting-children")
273
277
  end
274
278
  end
275
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
276
- local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
277
- if doNotHavePendingDependencies then
278
- moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
279
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
280
+ if rcall("EXISTS", parentKey) == 1 then
281
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
282
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
283
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
284
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
279
285
  end
286
+ end
287
+ end
288
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
289
+ parentId, timestamp)
290
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
291
+ if doNotHavePendingDependencies then
292
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
293
+ end
280
294
  end
281
295
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
282
296
  parentId, jobIdKey, returnvalue, timestamp )
283
297
  local processedSet = parentKey .. ":processed"
284
298
  rcall("HSET", processedSet, jobIdKey, returnvalue)
285
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
299
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
286
300
  end
287
301
  local function updateExistingJobsParent(parentKey, parent, parentData,
288
302
  parentDependenciesKey, completedKey,
@@ -1 +1 @@
1
- {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts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,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -93,12 +93,19 @@ end
93
93
  Validate and move or add dependencies to parent.
94
94
  ]]
95
95
  -- Includes
96
+ --[[
97
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
98
+ if no pending dependencies.
99
+ ]]
100
+ -- Includes
96
101
  --[[
97
102
  Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
98
103
  ]]
104
+ -- Includes
99
105
  --[[
100
- Validate and move parent to a wait status (wait, prioritized or delayed)
106
+ Move parent to a wait status (wait, prioritized or delayed)
101
107
  ]]
108
+ -- Includes
102
109
  --[[
103
110
  Add delay marker if needed.
104
111
  ]]
@@ -193,52 +200,59 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
193
200
  return waitKey, false
194
201
  end
195
202
  local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
196
- local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
197
- if isParentWaitingChildren > 0 then
198
- local parentWaitKey = parentQueueKey .. ":wait"
199
- local parentPausedKey = parentQueueKey .. ":paused"
200
- local parentActiveKey = parentQueueKey .. ":active"
201
- local parentMetaKey = parentQueueKey .. ":meta"
202
- local parentMarkerKey = parentQueueKey .. ":marker"
203
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
204
- local priority = tonumber(jobAttributes[1]) or 0
205
- local delay = tonumber(jobAttributes[2]) or 0
206
- -- ignore dependencies if any left
207
- rcall("HSET", parentKey, "igdp", 1)
208
- if delay > 0 then
209
- local delayedTimestamp = tonumber(timestamp) + delay
210
- local score = delayedTimestamp * 0x1000
211
- local parentDelayedKey = parentQueueKey .. ":delayed"
212
- rcall("ZADD", parentDelayedKey, score, parentId)
213
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
214
- delayedTimestamp)
215
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
203
+ local parentWaitKey = parentQueueKey .. ":wait"
204
+ local parentPausedKey = parentQueueKey .. ":paused"
205
+ local parentActiveKey = parentQueueKey .. ":active"
206
+ local parentMetaKey = parentQueueKey .. ":meta"
207
+ local parentMarkerKey = parentQueueKey .. ":marker"
208
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
209
+ local priority = tonumber(jobAttributes[1]) or 0
210
+ local delay = tonumber(jobAttributes[2]) or 0
211
+ -- ignore dependencies if any left
212
+ rcall("HSET", parentKey, "igdp", 1)
213
+ if delay > 0 then
214
+ local delayedTimestamp = tonumber(timestamp) + delay
215
+ local score = delayedTimestamp * 0x1000
216
+ local parentDelayedKey = parentQueueKey .. ":delayed"
217
+ rcall("ZADD", parentDelayedKey, score, parentId)
218
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
219
+ delayedTimestamp)
220
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
221
+ else
222
+ if priority == 0 then
223
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
224
+ parentWaitKey, parentPausedKey)
225
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
216
226
  else
217
- if priority == 0 then
218
- local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
219
- parentWaitKey, parentPausedKey)
220
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
221
- else
222
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
223
- addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
224
- parentQueueKey .. ":pc", isPausedOrMaxed)
225
- end
226
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
227
- "waiting-children")
227
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
228
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
229
+ parentQueueKey .. ":pc", isPausedOrMaxed)
228
230
  end
231
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
232
+ "waiting-children")
229
233
  end
230
234
  end
231
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
232
- local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
233
- if doNotHavePendingDependencies then
234
- moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
235
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
236
+ if rcall("EXISTS", parentKey) == 1 then
237
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
238
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
239
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
240
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
235
241
  end
242
+ end
243
+ end
244
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
245
+ parentId, timestamp)
246
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
247
+ if doNotHavePendingDependencies then
248
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
249
+ end
236
250
  end
237
251
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
238
252
  parentId, jobIdKey, returnvalue, timestamp )
239
253
  local processedSet = parentKey .. ":processed"
240
254
  rcall("HSET", processedSet, jobIdKey, returnvalue)
241
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
255
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
242
256
  end
243
257
  local function updateExistingJobsParent(parentKey, parent, parentData,
244
258
  parentDependenciesKey, completedKey,
@@ -1 +1 @@
1
- {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkWf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -155,12 +155,19 @@ end
155
155
  Validate and move or add dependencies to parent.
156
156
  ]]
157
157
  -- Includes
158
+ --[[
159
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
160
+ if no pending dependencies.
161
+ ]]
162
+ -- Includes
158
163
  --[[
159
164
  Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
160
165
  ]]
166
+ -- Includes
161
167
  --[[
162
- Validate and move parent to a wait status (wait, prioritized or delayed)
168
+ Move parent to a wait status (wait, prioritized or delayed)
163
169
  ]]
170
+ -- Includes
164
171
  --[[
165
172
  Add delay marker if needed.
166
173
  ]]
@@ -230,52 +237,59 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
230
237
  return waitKey, false
231
238
  end
232
239
  local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
233
- local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
234
- if isParentWaitingChildren > 0 then
235
- local parentWaitKey = parentQueueKey .. ":wait"
236
- local parentPausedKey = parentQueueKey .. ":paused"
237
- local parentActiveKey = parentQueueKey .. ":active"
238
- local parentMetaKey = parentQueueKey .. ":meta"
239
- local parentMarkerKey = parentQueueKey .. ":marker"
240
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
241
- local priority = tonumber(jobAttributes[1]) or 0
242
- local delay = tonumber(jobAttributes[2]) or 0
243
- -- ignore dependencies if any left
244
- rcall("HSET", parentKey, "igdp", 1)
245
- if delay > 0 then
246
- local delayedTimestamp = tonumber(timestamp) + delay
247
- local score = delayedTimestamp * 0x1000
248
- local parentDelayedKey = parentQueueKey .. ":delayed"
249
- rcall("ZADD", parentDelayedKey, score, parentId)
250
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
251
- delayedTimestamp)
252
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
240
+ local parentWaitKey = parentQueueKey .. ":wait"
241
+ local parentPausedKey = parentQueueKey .. ":paused"
242
+ local parentActiveKey = parentQueueKey .. ":active"
243
+ local parentMetaKey = parentQueueKey .. ":meta"
244
+ local parentMarkerKey = parentQueueKey .. ":marker"
245
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
246
+ local priority = tonumber(jobAttributes[1]) or 0
247
+ local delay = tonumber(jobAttributes[2]) or 0
248
+ -- ignore dependencies if any left
249
+ rcall("HSET", parentKey, "igdp", 1)
250
+ if delay > 0 then
251
+ local delayedTimestamp = tonumber(timestamp) + delay
252
+ local score = delayedTimestamp * 0x1000
253
+ local parentDelayedKey = parentQueueKey .. ":delayed"
254
+ rcall("ZADD", parentDelayedKey, score, parentId)
255
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
256
+ delayedTimestamp)
257
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
258
+ else
259
+ if priority == 0 then
260
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
261
+ parentWaitKey, parentPausedKey)
262
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
253
263
  else
254
- if priority == 0 then
255
- local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
256
- parentWaitKey, parentPausedKey)
257
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
258
- else
259
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
260
- addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
261
- parentQueueKey .. ":pc", isPausedOrMaxed)
262
- end
263
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
264
- "waiting-children")
264
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
265
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
266
+ parentQueueKey .. ":pc", isPausedOrMaxed)
265
267
  end
268
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
269
+ "waiting-children")
266
270
  end
267
271
  end
268
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
269
- local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
270
- if doNotHavePendingDependencies then
271
- moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
272
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
273
+ if rcall("EXISTS", parentKey) == 1 then
274
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
275
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
276
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
277
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
272
278
  end
279
+ end
280
+ end
281
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
282
+ parentId, timestamp)
283
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
284
+ if doNotHavePendingDependencies then
285
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
286
+ end
273
287
  end
274
288
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
275
289
  parentId, jobIdKey, returnvalue, timestamp )
276
290
  local processedSet = parentKey .. ":processed"
277
291
  rcall("HSET", processedSet, jobIdKey, returnvalue)
278
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
292
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
279
293
  end
280
294
  local function updateExistingJobsParent(parentKey, parent, parentData,
281
295
  parentDependenciesKey, completedKey,
@@ -1 +1 @@
1
- {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Vf,CAAC;AACW,QAAA,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;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -139,12 +139,19 @@ end
139
139
  Validate and move or add dependencies to parent.
140
140
  ]]
141
141
  -- Includes
142
+ --[[
143
+ Validate and move parent to a wait status (waiting, delayed or prioritized)
144
+ if no pending dependencies.
145
+ ]]
146
+ -- Includes
142
147
  --[[
143
148
  Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
144
149
  ]]
150
+ -- Includes
145
151
  --[[
146
- Validate and move parent to a wait status (wait, prioritized or delayed)
152
+ Move parent to a wait status (wait, prioritized or delayed)
147
153
  ]]
154
+ -- Includes
148
155
  --[[
149
156
  Add delay marker if needed.
150
157
  ]]
@@ -203,52 +210,59 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
203
210
  return false
204
211
  end
205
212
  local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
206
- local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
207
- if isParentWaitingChildren > 0 then
208
- local parentWaitKey = parentQueueKey .. ":wait"
209
- local parentPausedKey = parentQueueKey .. ":paused"
210
- local parentActiveKey = parentQueueKey .. ":active"
211
- local parentMetaKey = parentQueueKey .. ":meta"
212
- local parentMarkerKey = parentQueueKey .. ":marker"
213
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
214
- local priority = tonumber(jobAttributes[1]) or 0
215
- local delay = tonumber(jobAttributes[2]) or 0
216
- -- ignore dependencies if any left
217
- rcall("HSET", parentKey, "igdp", 1)
218
- if delay > 0 then
219
- local delayedTimestamp = tonumber(timestamp) + delay
220
- local score = delayedTimestamp * 0x1000
221
- local parentDelayedKey = parentQueueKey .. ":delayed"
222
- rcall("ZADD", parentDelayedKey, score, parentId)
223
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
224
- delayedTimestamp)
225
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
213
+ local parentWaitKey = parentQueueKey .. ":wait"
214
+ local parentPausedKey = parentQueueKey .. ":paused"
215
+ local parentActiveKey = parentQueueKey .. ":active"
216
+ local parentMetaKey = parentQueueKey .. ":meta"
217
+ local parentMarkerKey = parentQueueKey .. ":marker"
218
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
219
+ local priority = tonumber(jobAttributes[1]) or 0
220
+ local delay = tonumber(jobAttributes[2]) or 0
221
+ -- ignore dependencies if any left
222
+ rcall("HSET", parentKey, "igdp", 1)
223
+ if delay > 0 then
224
+ local delayedTimestamp = tonumber(timestamp) + delay
225
+ local score = delayedTimestamp * 0x1000
226
+ local parentDelayedKey = parentQueueKey .. ":delayed"
227
+ rcall("ZADD", parentDelayedKey, score, parentId)
228
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
229
+ delayedTimestamp)
230
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
231
+ else
232
+ if priority == 0 then
233
+ local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
234
+ parentWaitKey, parentPausedKey)
235
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
226
236
  else
227
- if priority == 0 then
228
- local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
229
- parentWaitKey, parentPausedKey)
230
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
231
- else
232
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
233
- addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
234
- parentQueueKey .. ":pc", isPausedOrMaxed)
235
- end
236
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
237
- "waiting-children")
237
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
238
+ addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
239
+ parentQueueKey .. ":pc", isPausedOrMaxed)
238
240
  end
241
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
242
+ "waiting-children")
239
243
  end
240
244
  end
241
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
242
- local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
243
- if doNotHavePendingDependencies then
244
- moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
245
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
246
+ if rcall("EXISTS", parentKey) == 1 then
247
+ local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
248
+ if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
249
+ rcall("ZREM", parentWaitingChildrenKey, parentId)
250
+ moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
245
251
  end
252
+ end
253
+ end
254
+ local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
255
+ parentId, timestamp)
256
+ local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
257
+ if doNotHavePendingDependencies then
258
+ moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
259
+ end
246
260
  end
247
261
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
248
262
  parentId, jobIdKey, returnvalue, timestamp )
249
263
  local processedSet = parentKey .. ":processed"
250
264
  rcall("HSET", processedSet, jobIdKey, returnvalue)
251
- moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
265
+ moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
252
266
  end
253
267
  local function updateExistingJobsParent(parentKey, parent, parentData,
254
268
  parentDependenciesKey, completedKey,
@@ -1 +1 @@
1
- {"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addSt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