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