bullmq 5.56.8 → 5.56.9

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 (37) hide show
  1. package/dist/cjs/classes/scripts.js +3 -3
  2. package/dist/cjs/classes/scripts.js.map +1 -1
  3. package/dist/cjs/commands/includes/moveJobToWait.lua +15 -0
  4. package/dist/cjs/commands/moveStalledJobsToWait-8.lua +3 -11
  5. package/dist/cjs/commands/{moveToWaitingChildren-8.lua → moveToWaitingChildren-7.lua} +12 -38
  6. package/dist/cjs/enums/error-code.js +1 -1
  7. package/dist/cjs/enums/error-code.js.map +1 -1
  8. package/dist/cjs/scripts/index.js +1 -1
  9. package/dist/cjs/scripts/moveStalledJobsToWait-8.js +12 -8
  10. package/dist/cjs/scripts/moveStalledJobsToWait-8.js.map +1 -1
  11. package/dist/cjs/scripts/moveToWaitingChildren-7.js +107 -0
  12. package/dist/cjs/scripts/moveToWaitingChildren-7.js.map +1 -0
  13. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  14. package/dist/cjs/version.js +1 -1
  15. package/dist/esm/classes/scripts.js +3 -3
  16. package/dist/esm/classes/scripts.js.map +1 -1
  17. package/dist/esm/commands/includes/moveJobToWait.lua +15 -0
  18. package/dist/esm/commands/moveStalledJobsToWait-8.lua +3 -11
  19. package/dist/esm/commands/{moveToWaitingChildren-8.lua → moveToWaitingChildren-7.lua} +12 -38
  20. package/dist/esm/enums/error-code.d.ts +1 -1
  21. package/dist/esm/enums/error-code.js +1 -1
  22. package/dist/esm/enums/error-code.js.map +1 -1
  23. package/dist/esm/scripts/index.d.ts +1 -1
  24. package/dist/esm/scripts/index.js +1 -1
  25. package/dist/esm/scripts/moveStalledJobsToWait-8.js +12 -8
  26. package/dist/esm/scripts/moveStalledJobsToWait-8.js.map +1 -1
  27. package/dist/esm/scripts/moveToWaitingChildren-7.js +104 -0
  28. package/dist/esm/scripts/moveToWaitingChildren-7.js.map +1 -0
  29. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  30. package/dist/esm/version.d.ts +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/package.json +3 -4
  33. package/dist/cjs/scripts/moveToWaitingChildren-8.js +0 -540
  34. package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +0 -1
  35. package/dist/esm/scripts/moveToWaitingChildren-8.js +0 -537
  36. package/dist/esm/scripts/moveToWaitingChildren-8.js.map +0 -1
  37. /package/dist/esm/scripts/{moveToWaitingChildren-8.d.ts → moveToWaitingChildren-7.d.ts} +0 -0
@@ -1,537 +0,0 @@
1
- const content = `--[[
2
- Moves job from active to waiting children set.
3
- Input:
4
- KEYS[1] active key
5
- KEYS[2] wait-children key
6
- KEYS[3] job key
7
- KEYS[4] job dependencies key
8
- KEYS[5] job unsuccessful key
9
- KEYS[6] stalled key
10
- KEYS[7] failed key
11
- KEYS[8] events key
12
- ARGV[1] token
13
- ARGV[2] child key
14
- ARGV[3] timestamp
15
- ARGV[4] jobId
16
- ARGV[5] prefix
17
- Output:
18
- 0 - OK
19
- 1 - There are not pending dependencies.
20
- -1 - Missing job.
21
- -2 - Missing lock
22
- -3 - Job not in active set
23
- ]]
24
- local rcall = redis.call
25
- local activeKey = KEYS[1]
26
- local waitingChildrenKey = KEYS[2]
27
- local jobKey = KEYS[3]
28
- local jobDependenciesKey = KEYS[4]
29
- local jobUnsuccessfulKey = KEYS[5]
30
- local stalledKey = KEYS[6]
31
- local failedKey = KEYS[7]
32
- local token = ARGV[1]
33
- local timestamp = ARGV[3]
34
- local jobId = ARGV[4]
35
- --- Includes
36
- --[[
37
- Function to recursively move from waitingChildren to failed.
38
- ]]
39
- -- Includes
40
- --[[
41
- Validate and move parent to a wait status (waiting, delayed or prioritized)
42
- if no pending dependencies.
43
- ]]
44
- -- Includes
45
- --[[
46
- Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
47
- ]]
48
- -- Includes
49
- --[[
50
- Move parent to a wait status (wait, prioritized or delayed)
51
- ]]
52
- -- Includes
53
- --[[
54
- Add delay marker if needed.
55
- ]]
56
- -- Includes
57
- --[[
58
- Function to return the next delayed job timestamp.
59
- ]]
60
- local function getNextDelayedTimestamp(delayedKey)
61
- local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
62
- if #result then
63
- local nextTimestamp = tonumber(result[2])
64
- if nextTimestamp ~= nil then
65
- return nextTimestamp / 0x1000
66
- end
67
- end
68
- end
69
- local function addDelayMarkerIfNeeded(markerKey, delayedKey)
70
- local nextTimestamp = getNextDelayedTimestamp(delayedKey)
71
- if nextTimestamp ~= nil then
72
- -- Replace the score of the marker with the newest known
73
- -- next timestamp.
74
- rcall("ZADD", markerKey, nextTimestamp, "1")
75
- end
76
- end
77
- --[[
78
- Function to add job in target list and add marker if needed.
79
- ]]
80
- -- Includes
81
- --[[
82
- Add marker if needed when a job is available.
83
- ]]
84
- local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
85
- if not isPausedOrMaxed then
86
- rcall("ZADD", markerKey, 0, "0")
87
- end
88
- end
89
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
90
- rcall(pushCmd, targetKey, jobId)
91
- addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
92
- end
93
- --[[
94
- Function to add job considering priority.
95
- ]]
96
- -- Includes
97
- --[[
98
- Function to get priority score.
99
- ]]
100
- local function getPriorityScore(priority, priorityCounterKey)
101
- local prioCounter = rcall("INCR", priorityCounterKey)
102
- return priority * 0x100000000 + prioCounter % 0x100000000
103
- end
104
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
105
- isPausedOrMaxed)
106
- local score = getPriorityScore(priority, priorityCounterKey)
107
- rcall("ZADD", prioritizedKey, score, jobId)
108
- addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
109
- end
110
- --[[
111
- Function to check if queue is paused or maxed
112
- (since an empty list and !EXISTS are not really the same).
113
- ]]
114
- local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
115
- local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
116
- if queueAttributes[1] then
117
- return true
118
- else
119
- if queueAttributes[2] then
120
- local activeCount = rcall("LLEN", activeKey)
121
- return activeCount >= tonumber(queueAttributes[2])
122
- end
123
- end
124
- return false
125
- end
126
- --[[
127
- Function to check for the meta.paused key to decide if we are paused or not
128
- (since an empty list and !EXISTS are not really the same).
129
- ]]
130
- local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
131
- local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
132
- if queueAttributes[1] then
133
- return pausedKey, true
134
- else
135
- if queueAttributes[2] then
136
- local activeCount = rcall("LLEN", activeKey)
137
- if activeCount >= tonumber(queueAttributes[2]) then
138
- return waitKey, true
139
- else
140
- return waitKey, false
141
- end
142
- end
143
- end
144
- return waitKey, false
145
- end
146
- local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
147
- local parentWaitKey = parentQueueKey .. ":wait"
148
- local parentPausedKey = parentQueueKey .. ":paused"
149
- local parentActiveKey = parentQueueKey .. ":active"
150
- local parentMetaKey = parentQueueKey .. ":meta"
151
- local parentMarkerKey = parentQueueKey .. ":marker"
152
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
153
- local priority = tonumber(jobAttributes[1]) or 0
154
- local delay = tonumber(jobAttributes[2]) or 0
155
- if delay > 0 then
156
- local delayedTimestamp = tonumber(timestamp) + delay
157
- local score = delayedTimestamp * 0x1000
158
- local parentDelayedKey = parentQueueKey .. ":delayed"
159
- rcall("ZADD", parentDelayedKey, score, parentId)
160
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
161
- delayedTimestamp)
162
- addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
163
- else
164
- if priority == 0 then
165
- local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
166
- parentWaitKey, parentPausedKey)
167
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
168
- else
169
- local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
170
- addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
171
- parentQueueKey .. ":pc", isPausedOrMaxed)
172
- end
173
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
174
- "waiting-children")
175
- end
176
- end
177
- local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
178
- if rcall("EXISTS", parentKey) == 1 then
179
- local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
180
- if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
181
- rcall("ZREM", parentWaitingChildrenKey, parentId)
182
- moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
183
- end
184
- end
185
- end
186
- local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
187
- parentId, timestamp)
188
- local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
189
- if doNotHavePendingDependencies then
190
- moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
191
- end
192
- end
193
- --[[
194
- Functions to remove jobs when removeOnFail option is provided.
195
- ]]
196
- -- Includes
197
- --[[
198
- Function to remove job.
199
- ]]
200
- -- Includes
201
- --[[
202
- Function to remove deduplication key if needed
203
- when a job is being removed.
204
- ]]
205
- local function removeDeduplicationKeyIfNeededOnRemoval(prefixKey,
206
- jobKey, jobId)
207
- local deduplicationId = rcall("HGET", jobKey, "deid")
208
- if deduplicationId then
209
- local deduplicationKey = prefixKey .. "de:" .. deduplicationId
210
- local currentJobId = rcall('GET', deduplicationKey)
211
- if currentJobId and currentJobId == jobId then
212
- return rcall("DEL", deduplicationKey)
213
- end
214
- end
215
- end
216
- --[[
217
- Function to remove job keys.
218
- ]]
219
- local function removeJobKeys(jobKey)
220
- return rcall("DEL", jobKey, jobKey .. ':logs', jobKey .. ':dependencies',
221
- jobKey .. ':processed', jobKey .. ':failed', jobKey .. ':unsuccessful')
222
- end
223
- --[[
224
- Check if this job has a parent. If so we will just remove it from
225
- the parent child list, but if it is the last child we should move the parent to "wait/paused"
226
- which requires code from "moveToFinished"
227
- ]]
228
- -- Includes
229
- --[[
230
- Functions to destructure job key.
231
- Just a bit of warning, these functions may be a bit slow and affect performance significantly.
232
- ]]
233
- local getJobIdFromKey = function (jobKey)
234
- return string.match(jobKey, ".*:(.*)")
235
- end
236
- local getJobKeyPrefix = function (jobKey, jobId)
237
- return string.sub(jobKey, 0, #jobKey - #jobId)
238
- end
239
- local function _moveParentToWait(parentPrefix, parentId, emitEvent)
240
- local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
241
- parentPrefix .. "wait", parentPrefix .. "paused")
242
- addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
243
- if emitEvent then
244
- local parentEventStream = parentPrefix .. "events"
245
- rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
246
- end
247
- end
248
- local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
249
- if parentKey then
250
- local parentDependenciesKey = parentKey .. ":dependencies"
251
- local result = rcall("SREM", parentDependenciesKey, jobKey)
252
- if result > 0 then
253
- local pendingDependencies = rcall("SCARD", parentDependenciesKey)
254
- if pendingDependencies == 0 then
255
- local parentId = getJobIdFromKey(parentKey)
256
- local parentPrefix = getJobKeyPrefix(parentKey, parentId)
257
- local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
258
- if numRemovedElements == 1 then
259
- if hard then -- remove parent in same queue
260
- if parentPrefix == baseKey then
261
- removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
262
- removeJobKeys(parentKey)
263
- if debounceId then
264
- rcall("DEL", parentPrefix .. "de:" .. debounceId)
265
- end
266
- else
267
- _moveParentToWait(parentPrefix, parentId)
268
- end
269
- else
270
- _moveParentToWait(parentPrefix, parentId, true)
271
- end
272
- end
273
- end
274
- return true
275
- end
276
- else
277
- local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
278
- local missedParentKey = parentAttributes[1]
279
- if( (type(missedParentKey) == "string") and missedParentKey ~= ""
280
- and (rcall("EXISTS", missedParentKey) == 1)) then
281
- local parentDependenciesKey = missedParentKey .. ":dependencies"
282
- local result = rcall("SREM", parentDependenciesKey, jobKey)
283
- if result > 0 then
284
- local pendingDependencies = rcall("SCARD", parentDependenciesKey)
285
- if pendingDependencies == 0 then
286
- local parentId = getJobIdFromKey(missedParentKey)
287
- local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
288
- local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
289
- if numRemovedElements == 1 then
290
- if hard then
291
- if parentPrefix == baseKey then
292
- removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
293
- removeJobKeys(missedParentKey)
294
- if parentAttributes[2] then
295
- rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
296
- end
297
- else
298
- _moveParentToWait(parentPrefix, parentId)
299
- end
300
- else
301
- _moveParentToWait(parentPrefix, parentId, true)
302
- end
303
- end
304
- end
305
- return true
306
- end
307
- end
308
- end
309
- return false
310
- end
311
- local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
312
- local jobKey = baseKey .. jobId
313
- removeParentDependencyKey(jobKey, hard, nil, baseKey)
314
- if shouldRemoveDeduplicationKey then
315
- removeDeduplicationKeyIfNeededOnRemoval(baseKey, jobKey, jobId)
316
- end
317
- removeJobKeys(jobKey)
318
- end
319
- --[[
320
- Functions to remove jobs by max age.
321
- ]]
322
- -- Includes
323
- local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
324
- shouldRemoveDebounceKey)
325
- local start = timestamp - maxAge * 1000
326
- local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
327
- for i, jobId in ipairs(jobIds) do
328
- removeJob(jobId, false, prefix, false --[[remove debounce key]])
329
- end
330
- rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
331
- end
332
- --[[
333
- Functions to remove jobs by max count.
334
- ]]
335
- -- Includes
336
- local function removeJobsByMaxCount(maxCount, targetSet, prefix)
337
- local start = maxCount
338
- local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
339
- for i, jobId in ipairs(jobIds) do
340
- removeJob(jobId, false, prefix, false --[[remove debounce key]])
341
- end
342
- rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
343
- end
344
- local function removeJobsOnFail(queueKeyPrefix, failedKey, jobId, opts, timestamp)
345
- local removeOnFailType = type(opts["removeOnFail"])
346
- if removeOnFailType == "number" then
347
- removeJobsByMaxCount(opts["removeOnFail"],
348
- failedKey, queueKeyPrefix)
349
- elseif removeOnFailType == "boolean" then
350
- if opts["removeOnFail"] then
351
- removeJob(jobId, false, queueKeyPrefix,
352
- false --[[remove debounce key]])
353
- rcall("ZREM", failedKey, jobId)
354
- end
355
- elseif removeOnFailType ~= "nil" then
356
- local maxAge = opts["removeOnFail"]["age"]
357
- local maxCount = opts["removeOnFail"]["count"]
358
- if maxAge ~= nil then
359
- removeJobsByMaxAge(timestamp, maxAge,
360
- failedKey, queueKeyPrefix)
361
- end
362
- if maxCount ~= nil and maxCount > 0 then
363
- removeJobsByMaxCount(maxCount, failedKey,
364
- queueKeyPrefix)
365
- end
366
- end
367
- end
368
- local moveParentToFailedIfNeeded = function (parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
369
- if rcall("EXISTS", parentKey) == 1 then
370
- local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
371
- local parentDelayedKey = parentQueueKey .. ":delayed"
372
- local parentPrioritizedKey = parentQueueKey .. ":prioritized"
373
- local parentWaitingChildrenOrDelayedKey
374
- local prevState
375
- if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
376
- parentWaitingChildrenOrDelayedKey = parentWaitingChildrenKey
377
- prevState = "waiting-children"
378
- elseif rcall("ZSCORE", parentDelayedKey, parentId) then
379
- parentWaitingChildrenOrDelayedKey = parentDelayedKey
380
- prevState = "delayed"
381
- rcall("HSET", parentKey, "delay", 0)
382
- end
383
- if parentWaitingChildrenOrDelayedKey then
384
- rcall("ZREM", parentWaitingChildrenOrDelayedKey, parentId)
385
- local parentQueuePrefix = parentQueueKey .. ":"
386
- local parentFailedKey = parentQueueKey .. ":failed"
387
- local deferredFailure = "child " .. jobIdKey .. " failed"
388
- rcall("HSET", parentKey, "defa", deferredFailure)
389
- moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
390
- else
391
- if not rcall("ZSCORE", parentQueueKey .. ":failed", parentId) then
392
- local deferredFailure = "child " .. jobIdKey .. " failed"
393
- rcall("HSET", parentKey, "defa", deferredFailure)
394
- end
395
- end
396
- end
397
- end
398
- local moveChildFromDependenciesIfNeeded = function (rawParentData, childKey, failedReason, timestamp)
399
- if rawParentData then
400
- local parentData = cjson.decode(rawParentData)
401
- local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
402
- local parentDependenciesChildrenKey = parentKey .. ":dependencies"
403
- if parentData['fpof'] then
404
- if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
405
- local parentUnsuccesssfulChildrenKey = parentKey .. ":unsuccessful"
406
- rcall("ZADD", parentUnsuccesssfulChildrenKey, timestamp, childKey)
407
- moveParentToFailedIfNeeded(
408
- parentData['queueKey'],
409
- parentKey,
410
- parentData['id'],
411
- childKey,
412
- timestamp
413
- )
414
- end
415
- elseif parentData['cpof'] then
416
- if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
417
- local parentFailedChildrenKey = parentKey .. ":failed"
418
- rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
419
- moveParentToWaitIfNeeded(parentData['queueKey'], parentKey, parentData['id'], timestamp)
420
- end
421
- elseif parentData['idof'] or parentData['rdof'] then
422
- if rcall("SREM", parentDependenciesChildrenKey, childKey) == 1 then
423
- moveParentToWaitIfNoPendingDependencies(parentData['queueKey'], parentDependenciesChildrenKey,
424
- parentKey, parentData['id'], timestamp)
425
- if parentData['idof'] then
426
- local parentFailedChildrenKey = parentKey .. ":failed"
427
- rcall("HSET", parentFailedChildrenKey, childKey, failedReason)
428
- end
429
- end
430
- end
431
- end
432
- end
433
- --[[
434
- Function to remove deduplication key if needed
435
- when a job is moved to completed or failed states.
436
- ]]
437
- local function removeDeduplicationKeyIfNeededOnFinalization(prefixKey,
438
- deduplicationId, jobId)
439
- if deduplicationId then
440
- local deduplicationKey = prefixKey .. "de:" .. deduplicationId
441
- local pttl = rcall("PTTL", deduplicationKey)
442
- if pttl == 0 then
443
- return rcall("DEL", deduplicationKey)
444
- end
445
- if pttl == -1 then
446
- local currentJobId = rcall('GET', deduplicationKey)
447
- if currentJobId and currentJobId == jobId then
448
- return rcall("DEL", deduplicationKey)
449
- end
450
- end
451
- end
452
- end
453
- local function removeLock(jobKey, stalledKey, token, jobId)
454
- if token ~= "0" then
455
- local lockKey = jobKey .. ':lock'
456
- local lockToken = rcall("GET", lockKey)
457
- if lockToken == token then
458
- rcall("DEL", lockKey)
459
- rcall("SREM", stalledKey, jobId)
460
- else
461
- if lockToken then
462
- -- Lock exists but token does not match
463
- return -6
464
- else
465
- -- Lock is missing completely
466
- return -2
467
- end
468
- end
469
- end
470
- return 0
471
- end
472
- local function removeJobFromActive(activeKey, stalledKey, jobKey, jobId,
473
- token)
474
- local errorCode = removeLock(jobKey, stalledKey, token, jobId)
475
- if errorCode < 0 then
476
- return errorCode
477
- end
478
- local numRemovedElements = rcall("LREM", activeKey, -1, jobId)
479
- if(numRemovedElements < 1) then
480
- return -3
481
- end
482
- return 0
483
- end
484
- local function moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, jobKey, jobId,
485
- timestamp, token)
486
- local errorCode = removeJobFromActive(activeKey, stalledKey, jobKey, jobId, token)
487
- if errorCode < 0 then
488
- return errorCode
489
- end
490
- local score = tonumber(timestamp)
491
- rcall("ZADD", waitingChildrenKey, score, jobId)
492
- return 0
493
- end
494
- if rcall("EXISTS", jobKey) == 1 then
495
- if rcall("ZCARD", jobUnsuccessfulKey) ~= 0 then
496
- local errorCode = removeJobFromActive(activeKey, stalledKey, jobKey, jobId, token)
497
- if errorCode < 0 then
498
- return errorCode
499
- end
500
- -- TODO: refactor this logic in an include later
501
- local jobAttributes = rcall("HMGET", jobKey, "parent", "deid", "opts")
502
- removeDeduplicationKeyIfNeededOnFinalization(ARGV[5], jobAttributes[2], jobId)
503
- local failedReason = "children are failed"
504
- rcall("ZADD", failedKey, timestamp, jobId)
505
- rcall("HSET", jobKey, "finishedOn", timestamp)
506
- rcall("XADD", KEYS[8], "*", "event", "failed", "jobId", jobId, "failedReason",
507
- failedReason, "prev", "active")
508
- local rawParentData = jobAttributes[1]
509
- local rawOpts = jobAttributes[3]
510
- local opts = cjson.decode(rawOpts)
511
- moveChildFromDependenciesIfNeeded(rawParentData, jobKey, failedReason, timestamp)
512
- removeJobsOnFail(ARGV[5], failedKey, jobId, opts, timestamp)
513
- return 0
514
- else
515
- if ARGV[2] ~= "" then
516
- if rcall("SISMEMBER", jobDependenciesKey, ARGV[2]) ~= 0 then
517
- return moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, jobKey, jobId,
518
- timestamp, token)
519
- end
520
- return 1
521
- else
522
- if rcall("SCARD", jobDependenciesKey) ~= 0 then
523
- return moveToWaitingChildren(activeKey, waitingChildrenKey, stalledKey, jobKey, jobId,
524
- timestamp, token)
525
- end
526
- return 1
527
- end
528
- end
529
- end
530
- return -1
531
- `;
532
- export const moveToWaitingChildren = {
533
- name: 'moveToWaitingChildren',
534
- content,
535
- keys: 8,
536
- };
537
- //# sourceMappingURL=moveToWaitingChildren-8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moveToWaitingChildren-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkhBf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}