bullmq 5.10.3 → 5.11.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.
- package/dist/cjs/classes/job.js +6 -0
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/classes/queue-keys.js +2 -1
- package/dist/cjs/classes/queue-keys.js.map +1 -1
- package/dist/cjs/classes/queue.js +9 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.js +2 -1
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/addDelayedJob-6.lua +11 -1
- package/dist/cjs/commands/addParentJob-4.lua +10 -1
- package/dist/cjs/commands/addPrioritizedJob-8.lua +11 -2
- package/dist/cjs/commands/addStandardJob-8.lua +11 -2
- package/dist/cjs/commands/includes/cleanList.lua +1 -1
- package/dist/cjs/commands/includes/cleanSet.lua +2 -2
- package/dist/cjs/commands/includes/debounceJob.lua +23 -0
- package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
- package/dist/cjs/commands/includes/removeDebounceKey.lua +12 -0
- package/dist/cjs/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
- package/dist/cjs/commands/includes/removeJob.lua +5 -1
- package/dist/cjs/commands/includes/removeJobs.lua +1 -1
- package/dist/cjs/commands/includes/removeJobsByMaxAge.lua +3 -2
- package/dist/cjs/commands/includes/removeJobsByMaxCount.lua +1 -1
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +11 -4
- package/dist/cjs/commands/includes/storeJob.lua +7 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +6 -2
- package/dist/cjs/commands/moveToFinished-14.lua +14 -11
- package/dist/cjs/commands/removeChildDependency-1.lua +1 -1
- package/dist/cjs/commands/removeJob-2.lua +3 -1
- package/dist/cjs/commands/{removeRepeatable-2.lua → removeRepeatable-3.lua} +4 -2
- package/dist/cjs/interfaces/debounce-options.js +3 -0
- package/dist/cjs/interfaces/debounce-options.js.map +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/scripts/addDelayedJob-6.js +34 -1
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +34 -1
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +34 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +34 -1
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
- package/dist/cjs/scripts/cleanJobsInSet-2.js +28 -8
- package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/cjs/scripts/drain-4.js +26 -6
- package/dist/cjs/scripts/drain-4.js.map +1 -1
- package/dist/cjs/scripts/index.js +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +49 -13
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +56 -21
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +26 -6
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeChildDependency-1.js +12 -5
- package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/cjs/scripts/removeJob-2.js +23 -5
- package/dist/cjs/scripts/removeJob-2.js.map +1 -1
- package/dist/cjs/scripts/{removeRepeatable-2.js → removeRepeatable-3.js} +6 -4
- package/dist/cjs/scripts/removeRepeatable-3.js.map +1 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/job.d.ts +4 -0
- package/dist/esm/classes/job.js +6 -0
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue-events.d.ts +8 -0
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/classes/queue-keys.js +2 -1
- package/dist/esm/classes/queue-keys.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +6 -0
- package/dist/esm/classes/queue.js +9 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.js +2 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/addDelayedJob-6.lua +11 -1
- package/dist/esm/commands/addParentJob-4.lua +10 -1
- package/dist/esm/commands/addPrioritizedJob-8.lua +11 -2
- package/dist/esm/commands/addStandardJob-8.lua +11 -2
- package/dist/esm/commands/includes/cleanList.lua +1 -1
- package/dist/esm/commands/includes/cleanSet.lua +2 -2
- package/dist/esm/commands/includes/debounceJob.lua +23 -0
- package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
- package/dist/esm/commands/includes/removeDebounceKey.lua +12 -0
- package/dist/esm/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
- package/dist/esm/commands/includes/removeJob.lua +5 -1
- package/dist/esm/commands/includes/removeJobs.lua +1 -1
- package/dist/esm/commands/includes/removeJobsByMaxAge.lua +3 -2
- package/dist/esm/commands/includes/removeJobsByMaxCount.lua +1 -1
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +11 -4
- package/dist/esm/commands/includes/storeJob.lua +7 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +6 -2
- package/dist/esm/commands/moveToFinished-14.lua +14 -11
- package/dist/esm/commands/removeChildDependency-1.lua +1 -1
- package/dist/esm/commands/removeJob-2.lua +3 -1
- package/dist/esm/commands/{removeRepeatable-2.lua → removeRepeatable-3.lua} +4 -2
- package/dist/esm/interfaces/debounce-options.d.ts +13 -0
- package/dist/esm/interfaces/debounce-options.js +2 -0
- package/dist/esm/interfaces/debounce-options.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +1 -0
- package/dist/esm/interfaces/index.js +1 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/job-json.d.ts +2 -0
- package/dist/esm/scripts/addDelayedJob-6.js +34 -1
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +34 -1
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +34 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +34 -1
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
- package/dist/esm/scripts/cleanJobsInSet-2.js +28 -8
- package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/esm/scripts/drain-4.js +26 -6
- package/dist/esm/scripts/drain-4.js.map +1 -1
- package/dist/esm/scripts/index.d.ts +1 -1
- package/dist/esm/scripts/index.js +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +49 -13
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +56 -21
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +26 -6
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeChildDependency-1.js +12 -5
- package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/esm/scripts/removeJob-2.js +23 -5
- package/dist/esm/scripts/removeJob-2.js.map +1 -1
- package/dist/esm/scripts/{removeRepeatable-2.js → removeRepeatable-3.js} +6 -4
- package/dist/esm/scripts/removeRepeatable-3.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/types/job-options.d.ts +9 -1
- package/package.json +1 -1
- package/dist/cjs/scripts/removeRepeatable-2.js.map +0 -1
- package/dist/esm/scripts/removeRepeatable-2.js.map +0 -1
- /package/dist/esm/scripts/{removeRepeatable-2.d.ts → removeRepeatable-3.d.ts} +0 -0
@@ -263,6 +263,18 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
end
|
266
|
+
--[[
|
267
|
+
Function to remove debounce key if needed.
|
268
|
+
]]
|
269
|
+
local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
|
270
|
+
if debounceId then
|
271
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
272
|
+
local pttl = rcall("PTTL", debounceKey)
|
273
|
+
if pttl == 0 or pttl == -1 then
|
274
|
+
rcall("DEL", debounceKey)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
266
278
|
local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
267
279
|
if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
|
268
280
|
rcall("ZADD", parentQueueKey .. ":failed", timestamp, parentId)
|
@@ -270,9 +282,10 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
|
|
270
282
|
rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
271
283
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
272
284
|
failedReason, "prev", "waiting-children")
|
273
|
-
local
|
274
|
-
|
275
|
-
|
285
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
|
286
|
+
removeDebounceKeyIfNeeded(parentQueueKey, jobAttributes[2])
|
287
|
+
if jobAttributes[1] then
|
288
|
+
local parentData = cjson.decode(jobAttributes[1])
|
276
289
|
if parentData['fpof'] then
|
277
290
|
moveParentFromWaitingChildrenToFailed(
|
278
291
|
parentData['queueKey'],
|
@@ -373,6 +386,16 @@ end
|
|
373
386
|
Function to remove job.
|
374
387
|
]]
|
375
388
|
-- Includes
|
389
|
+
--[[
|
390
|
+
Function to remove debounce key.
|
391
|
+
]]
|
392
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
393
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
394
|
+
if debounceId then
|
395
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
396
|
+
rcall("DEL", debounceKey)
|
397
|
+
end
|
398
|
+
end
|
376
399
|
--[[
|
377
400
|
Check if this job has a parent. If so we will just remove it from
|
378
401
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
@@ -398,7 +421,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
398
421
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
399
422
|
end
|
400
423
|
end
|
401
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
424
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
402
425
|
if parentKey then
|
403
426
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
404
427
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -411,8 +434,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
411
434
|
if numRemovedElements == 1 then
|
412
435
|
if hard then -- remove parent in same queue
|
413
436
|
if parentPrefix == baseKey then
|
414
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
437
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
415
438
|
removeJobKeys(parentKey)
|
439
|
+
if debounceId then
|
440
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
441
|
+
end
|
416
442
|
else
|
417
443
|
moveParentToWait(parentPrefix, parentId)
|
418
444
|
end
|
@@ -424,7 +450,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
424
450
|
return true
|
425
451
|
end
|
426
452
|
else
|
427
|
-
local
|
453
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
454
|
+
local missedParentKey = parentAttributes[1]
|
428
455
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
429
456
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
430
457
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -438,8 +465,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
438
465
|
if numRemovedElements == 1 then
|
439
466
|
if hard then
|
440
467
|
if parentPrefix == baseKey then
|
441
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
468
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
442
469
|
removeJobKeys(missedParentKey)
|
470
|
+
if parentAttributes[2] then
|
471
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
472
|
+
end
|
443
473
|
else
|
444
474
|
moveParentToWait(parentPrefix, parentId)
|
445
475
|
end
|
@@ -454,16 +484,20 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
454
484
|
end
|
455
485
|
return false
|
456
486
|
end
|
457
|
-
local function removeJob(jobId, hard, baseKey)
|
487
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
458
488
|
local jobKey = baseKey .. jobId
|
459
489
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
490
|
+
if shouldRemoveDebounceKey then
|
491
|
+
removeDebounceKey(baseKey, jobKey)
|
492
|
+
end
|
460
493
|
removeJobKeys(jobKey)
|
461
494
|
end
|
462
|
-
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix
|
495
|
+
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
|
496
|
+
shouldRemoveDebounceKey)
|
463
497
|
local start = timestamp - maxAge * 1000
|
464
498
|
local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
|
465
499
|
for i, jobId in ipairs(jobIds) do
|
466
|
-
removeJob(jobId, false, prefix)
|
500
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
467
501
|
end
|
468
502
|
rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
|
469
503
|
end
|
@@ -475,7 +509,7 @@ local function removeJobsByMaxCount(maxCount, targetSet, prefix)
|
|
475
509
|
local start = maxCount
|
476
510
|
local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
|
477
511
|
for i, jobId in ipairs(jobIds) do
|
478
|
-
removeJob(jobId, false, prefix)
|
512
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
479
513
|
end
|
480
514
|
rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
|
481
515
|
end
|
@@ -546,12 +580,12 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
546
580
|
if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
|
547
581
|
return -4
|
548
582
|
end
|
549
|
-
local
|
550
|
-
local parentKey =
|
583
|
+
local jobAttributes = rcall("HMGET", jobIdKey, "parentKey", "parent", "deid")
|
584
|
+
local parentKey = jobAttributes[1] or ""
|
551
585
|
local parentId = ""
|
552
586
|
local parentQueueKey = ""
|
553
|
-
if
|
554
|
-
local jsonDecodedParent = cjson.decode(
|
587
|
+
if jobAttributes[2] ~= false then
|
588
|
+
local jsonDecodedParent = cjson.decode(jobAttributes[2])
|
555
589
|
parentId = jsonDecodedParent['id']
|
556
590
|
parentQueueKey = jsonDecodedParent['queueKey']
|
557
591
|
end
|
@@ -564,6 +598,8 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
564
598
|
local metaKey = KEYS[9]
|
565
599
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
566
600
|
trimEvents(metaKey, eventStreamKey)
|
601
|
+
local prefix = ARGV[7]
|
602
|
+
removeDebounceKeyIfNeeded(prefix, jobAttributes[3])
|
567
603
|
-- If job has a parent we need to
|
568
604
|
-- 1) remove this job id from parents dependencies
|
569
605
|
-- 2) move the job Id to parent "processed" set
|
@@ -608,7 +644,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
608
644
|
rcall("HMSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)
|
609
645
|
-- "returnvalue" / "failedReason" and "finishedOn"
|
610
646
|
-- Remove old jobs?
|
611
|
-
local prefix = ARGV[7]
|
612
647
|
if maxAge ~= nil then
|
613
648
|
removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
|
614
649
|
end
|
@@ -621,7 +656,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
621
656
|
-- TODO: when a child is removed when finished, result or failure in parent
|
622
657
|
-- must not be deleted, those value references should be deleted when the parent
|
623
658
|
-- is deleted
|
624
|
-
removeParentDependencyKey(jobIdKey, false, parentKey)
|
659
|
+
removeParentDependencyKey(jobIdKey, false, parentKey, jobAttributes[3])
|
625
660
|
end
|
626
661
|
end
|
627
662
|
rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3],
|
@@ -641,7 +676,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
641
676
|
if (ARGV[6] == "1") then
|
642
677
|
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])
|
643
678
|
-- Check if there are delayed jobs that can be promoted
|
644
|
-
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey,
|
679
|
+
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, prefix,
|
645
680
|
timestamp, KEYS[10], isPausedOrMaxed)
|
646
681
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
647
682
|
-- Check if we are rate limited first.
|
@@ -659,19 +694,19 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
659
694
|
if jobId == "0:0" then
|
660
695
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
|
661
696
|
KEYS[10])
|
662
|
-
return prepareJobForProcessing(
|
697
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
663
698
|
timestamp, maxJobs,
|
664
699
|
opts)
|
665
700
|
end
|
666
701
|
else
|
667
|
-
return prepareJobForProcessing(
|
702
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
668
703
|
timestamp, maxJobs,
|
669
704
|
opts)
|
670
705
|
end
|
671
706
|
else
|
672
707
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
|
673
708
|
if jobId then
|
674
|
-
return prepareJobForProcessing(
|
709
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
675
710
|
timestamp, maxJobs,
|
676
711
|
opts)
|
677
712
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+tBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -24,6 +24,16 @@ local rcall = redis.call
|
|
24
24
|
Function to remove job.
|
25
25
|
]]
|
26
26
|
-- Includes
|
27
|
+
--[[
|
28
|
+
Function to remove debounce key.
|
29
|
+
]]
|
30
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
31
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
32
|
+
if debounceId then
|
33
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
34
|
+
rcall("DEL", debounceKey)
|
35
|
+
end
|
36
|
+
end
|
27
37
|
--[[
|
28
38
|
Function to remove job keys.
|
29
39
|
]]
|
@@ -92,7 +102,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
92
102
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
93
103
|
end
|
94
104
|
end
|
95
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
105
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
96
106
|
if parentKey then
|
97
107
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
98
108
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -105,8 +115,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
105
115
|
if numRemovedElements == 1 then
|
106
116
|
if hard then -- remove parent in same queue
|
107
117
|
if parentPrefix == baseKey then
|
108
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
118
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
109
119
|
removeJobKeys(parentKey)
|
120
|
+
if debounceId then
|
121
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
122
|
+
end
|
110
123
|
else
|
111
124
|
moveParentToWait(parentPrefix, parentId)
|
112
125
|
end
|
@@ -118,7 +131,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
118
131
|
return true
|
119
132
|
end
|
120
133
|
else
|
121
|
-
local
|
134
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
135
|
+
local missedParentKey = parentAttributes[1]
|
122
136
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
123
137
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
124
138
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -132,8 +146,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
132
146
|
if numRemovedElements == 1 then
|
133
147
|
if hard then
|
134
148
|
if parentPrefix == baseKey then
|
135
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
149
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
136
150
|
removeJobKeys(missedParentKey)
|
151
|
+
if parentAttributes[2] then
|
152
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
153
|
+
end
|
137
154
|
else
|
138
155
|
moveParentToWait(parentPrefix, parentId)
|
139
156
|
end
|
@@ -148,14 +165,17 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
148
165
|
end
|
149
166
|
return false
|
150
167
|
end
|
151
|
-
local function removeJob(jobId, hard, baseKey)
|
168
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
152
169
|
local jobKey = baseKey .. jobId
|
153
170
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
171
|
+
if shouldRemoveDebounceKey then
|
172
|
+
removeDebounceKey(baseKey, jobKey)
|
173
|
+
end
|
154
174
|
removeJobKeys(jobKey)
|
155
175
|
end
|
156
176
|
local function removeJobs(keys, hard, baseKey, max)
|
157
177
|
for i, key in ipairs(keys) do
|
158
|
-
removeJob(key, hard, baseKey)
|
178
|
+
removeJob(key, hard, baseKey, true --[[remove debounce key]])
|
159
179
|
end
|
160
180
|
return max - #keys
|
161
181
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmTf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -83,7 +83,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
83
83
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
84
84
|
end
|
85
85
|
end
|
86
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
86
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
87
87
|
if parentKey then
|
88
88
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
89
89
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -96,8 +96,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
96
96
|
if numRemovedElements == 1 then
|
97
97
|
if hard then -- remove parent in same queue
|
98
98
|
if parentPrefix == baseKey then
|
99
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
99
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
100
100
|
removeJobKeys(parentKey)
|
101
|
+
if debounceId then
|
102
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
103
|
+
end
|
101
104
|
else
|
102
105
|
moveParentToWait(parentPrefix, parentId)
|
103
106
|
end
|
@@ -109,7 +112,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
109
112
|
return true
|
110
113
|
end
|
111
114
|
else
|
112
|
-
local
|
115
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
116
|
+
local missedParentKey = parentAttributes[1]
|
113
117
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
114
118
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
115
119
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -123,8 +127,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
123
127
|
if numRemovedElements == 1 then
|
124
128
|
if hard then
|
125
129
|
if parentPrefix == baseKey then
|
126
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
130
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
127
131
|
removeJobKeys(missedParentKey)
|
132
|
+
if parentAttributes[2] then
|
133
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
134
|
+
end
|
128
135
|
else
|
129
136
|
moveParentToWait(parentPrefix, parentId)
|
130
137
|
end
|
@@ -141,7 +148,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
141
148
|
end
|
142
149
|
if rcall("EXISTS", jobKey) ~= 1 then return -1 end
|
143
150
|
if rcall("EXISTS", parentKey) ~= 1 then return -5 end
|
144
|
-
if removeParentDependencyKey(jobKey, false, parentKey, KEYS[1]) then
|
151
|
+
if removeParentDependencyKey(jobKey, false, parentKey, KEYS[1], nil) then
|
145
152
|
rcall("HDEL", jobKey, "parentKey", "parent")
|
146
153
|
return 0
|
147
154
|
else
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"removeChildDependency-1.js","sourceRoot":"","sources":["../../../src/scripts/removeChildDependency-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"removeChildDependency-1.js","sourceRoot":"","sources":["../../../src/scripts/removeChildDependency-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2JZ,CAAC;AACL,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -62,6 +62,16 @@ local function isLocked( prefix, jobId, removeChildren)
|
|
62
62
|
end
|
63
63
|
return true
|
64
64
|
end
|
65
|
+
--[[
|
66
|
+
Function to remove debounce key.
|
67
|
+
]]
|
68
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
69
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
70
|
+
if debounceId then
|
71
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
72
|
+
rcall("DEL", debounceKey)
|
73
|
+
end
|
74
|
+
end
|
65
75
|
--[[
|
66
76
|
Function to remove from any state.
|
67
77
|
returns:
|
@@ -152,7 +162,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
152
162
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
153
163
|
end
|
154
164
|
end
|
155
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
165
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
156
166
|
if parentKey then
|
157
167
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
158
168
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -165,8 +175,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
165
175
|
if numRemovedElements == 1 then
|
166
176
|
if hard then -- remove parent in same queue
|
167
177
|
if parentPrefix == baseKey then
|
168
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
178
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
169
179
|
removeJobKeys(parentKey)
|
180
|
+
if debounceId then
|
181
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
182
|
+
end
|
170
183
|
else
|
171
184
|
moveParentToWait(parentPrefix, parentId)
|
172
185
|
end
|
@@ -178,7 +191,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
178
191
|
return true
|
179
192
|
end
|
180
193
|
else
|
181
|
-
local
|
194
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
195
|
+
local missedParentKey = parentAttributes[1]
|
182
196
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
183
197
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
184
198
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -192,8 +206,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
192
206
|
if numRemovedElements == 1 then
|
193
207
|
if hard then
|
194
208
|
if parentPrefix == baseKey then
|
195
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
209
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
196
210
|
removeJobKeys(missedParentKey)
|
211
|
+
if parentAttributes[2] then
|
212
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
213
|
+
end
|
197
214
|
else
|
198
215
|
moveParentToWait(parentPrefix, parentId)
|
199
216
|
end
|
@@ -210,7 +227,7 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
210
227
|
end
|
211
228
|
local function removeJob( prefix, jobId, parentKey, removeChildren)
|
212
229
|
local jobKey = prefix .. jobId;
|
213
|
-
removeParentDependencyKey(jobKey, false, parentKey)
|
230
|
+
removeParentDependencyKey(jobKey, false, parentKey, nil)
|
214
231
|
if removeChildren == "1" then
|
215
232
|
-- Check if this job has children
|
216
233
|
-- If so, we are going to try to remove the children recursively in deep first way because
|
@@ -243,6 +260,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
243
260
|
end
|
244
261
|
end
|
245
262
|
local prev = removeJobFromAnyState(prefix, jobId)
|
263
|
+
removeDebounceKey(prefix, jobKey)
|
246
264
|
if removeJobKeys(jobKey) > 0 then
|
247
265
|
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
248
266
|
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"removeJob-2.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"removeJob-2.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmRf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -3,6 +3,7 @@ const content = `--[[
|
|
3
3
|
Input:
|
4
4
|
KEYS[1] repeat jobs key
|
5
5
|
KEYS[2] delayed jobs key
|
6
|
+
KEYS[3] events key
|
6
7
|
ARGV[1] old repeat job id
|
7
8
|
ARGV[2] options concat
|
8
9
|
ARGV[3] repeat job key
|
@@ -29,7 +30,7 @@ if millis then
|
|
29
30
|
local repeatJobId = ARGV[1] .. millis
|
30
31
|
if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then
|
31
32
|
removeJobKeys(ARGV[4] .. repeatJobId)
|
32
|
-
rcall("XADD",
|
33
|
+
rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed");
|
33
34
|
end
|
34
35
|
end
|
35
36
|
if(rcall("ZREM", KEYS[1], ARGV[2]) == 1) then
|
@@ -42,10 +43,11 @@ if millis then
|
|
42
43
|
local repeatJobId = "repeat:" .. ARGV[3] .. ":" .. millis
|
43
44
|
if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then
|
44
45
|
removeJobKeys(ARGV[4] .. repeatJobId)
|
45
|
-
rcall("XADD",
|
46
|
+
rcall("XADD", KEYS[3], "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed")
|
46
47
|
end
|
47
48
|
end
|
48
49
|
if(rcall("ZREM", KEYS[1], ARGV[3]) == 1) then
|
50
|
+
rcall("DEL", KEYS[1] .. ":" .. ARGV[3])
|
49
51
|
return 0
|
50
52
|
end
|
51
53
|
return 1
|
@@ -53,6 +55,6 @@ return 1
|
|
53
55
|
export const removeRepeatable = {
|
54
56
|
name: 'removeRepeatable',
|
55
57
|
content,
|
56
|
-
keys:
|
58
|
+
keys: 3,
|
57
59
|
};
|
58
|
-
//# sourceMappingURL=removeRepeatable-
|
60
|
+
//# sourceMappingURL=removeRepeatable-3.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"removeRepeatable-3.js","sourceRoot":"","sources":["../../../src/scripts/removeRepeatable-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|