bullmq 5.62.1 → 5.62.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.
- package/dist/cjs/commands/addJobScheduler-11.lua +30 -23
- package/dist/cjs/scripts/addJobScheduler-11.js +27 -20
- package/dist/cjs/scripts/addJobScheduler-11.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/commands/addJobScheduler-11.lua +30 -23
- package/dist/esm/scripts/addJobScheduler-11.js +27 -20
- package/dist/esm/scripts/addJobScheduler-11.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -28,8 +28,7 @@ const content = `--[[
|
|
|
28
28
|
ARGV[9] producer key
|
|
29
29
|
Output:
|
|
30
30
|
repeatableKey - OK
|
|
31
|
-
]]
|
|
32
|
-
local rcall = redis.call
|
|
31
|
+
]] local rcall = redis.call
|
|
33
32
|
local repeatKey = KEYS[1]
|
|
34
33
|
local delayedKey = KEYS[2]
|
|
35
34
|
local waitKey = KEYS[3]
|
|
@@ -457,8 +456,8 @@ if every then
|
|
|
457
456
|
local startDate = schedulerOpts['startDate']
|
|
458
457
|
nextMillis, newOffset = getJobSchedulerEveryNextMillis(prevMillis, every, now, offset, startDate)
|
|
459
458
|
end
|
|
460
|
-
local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId,
|
|
461
|
-
|
|
459
|
+
local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, jobId, metaKey,
|
|
460
|
+
eventsKey)
|
|
462
461
|
if rcall("ZSCORE", delayedKey, jobId) then
|
|
463
462
|
removeJob(jobId, true, prefixKey, true --[[remove debounce key]] )
|
|
464
463
|
rcall("ZREM", delayedKey, jobId)
|
|
@@ -479,28 +478,33 @@ local function removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, wai
|
|
|
479
478
|
end
|
|
480
479
|
return false
|
|
481
480
|
end
|
|
482
|
-
local
|
|
483
|
-
if prevMillis then
|
|
481
|
+
local removedPrevJob = false
|
|
482
|
+
if prevMillis then
|
|
484
483
|
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
|
485
484
|
local currentJobKey = schedulerKey .. ":" .. prevMillis
|
|
486
485
|
-- In theory it should always exist the currentJobKey if there is a prevMillis unless something has
|
|
487
486
|
-- gone really wrong.
|
|
488
487
|
if rcall("EXISTS", currentJobKey) == 1 then
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
removedPrevJob = removeJobFromScheduler(prefixKey, delayedKey, prioritizedKey, waitKey, pausedKey, currentJobId,
|
|
489
|
+
metaKey, eventsKey)
|
|
491
490
|
end
|
|
492
491
|
end
|
|
493
|
-
if
|
|
492
|
+
if removedPrevJob then
|
|
494
493
|
-- The jobs has been removed and we want to replace it, so lets use the same millis.
|
|
495
|
-
|
|
496
|
-
|
|
494
|
+
if every then
|
|
495
|
+
nextMillis = prevMillis
|
|
496
|
+
end
|
|
497
|
+
else
|
|
497
498
|
-- Special case where no job was removed, and we need to add the next iteration.
|
|
498
499
|
schedulerOpts['offset'] = newOffset
|
|
499
500
|
end
|
|
500
501
|
-- Check for job ID collision with existing jobs (in any state)
|
|
501
502
|
local jobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
|
|
502
503
|
local jobKey = prefixKey .. jobId
|
|
503
|
-
-- If there's already a job with this ID,
|
|
504
|
+
-- If there's already a job with this ID, in a state
|
|
505
|
+
-- that is not updatable (active, completed, failed) we must
|
|
506
|
+
-- handle the collision
|
|
507
|
+
local hasCollision = false
|
|
504
508
|
if rcall("EXISTS", jobKey) == 1 then
|
|
505
509
|
if every then
|
|
506
510
|
-- For 'every' case: try next time slot to avoid collision
|
|
@@ -516,8 +520,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
516
520
|
return -11 -- SchedulerJobSlotsBusy
|
|
517
521
|
end
|
|
518
522
|
else
|
|
519
|
-
|
|
520
|
-
return -10 -- SchedulerJobIdCollision
|
|
523
|
+
hasCollision = true
|
|
521
524
|
end
|
|
522
525
|
end
|
|
523
526
|
local delay = nextMillis - now
|
|
@@ -526,12 +529,16 @@ if delay < 0 then
|
|
|
526
529
|
delay = 0
|
|
527
530
|
end
|
|
528
531
|
local nextJobKey = schedulerKey .. ":" .. nextMillis
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
KEYS[11], metaKey, prioritizedKey, KEYS[10],
|
|
534
|
-
|
|
532
|
+
if not hasCollision or removedPrevJob then
|
|
533
|
+
-- jobId already calculated above during collision check
|
|
534
|
+
storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, templateData, templateOpts)
|
|
535
|
+
rcall("INCR", KEYS[8])
|
|
536
|
+
addJobFromScheduler(nextJobKey, jobId, jobOpts, waitKey, pausedKey, KEYS[11], metaKey, prioritizedKey, KEYS[10],
|
|
537
|
+
delayedKey, KEYS[7], eventsKey, schedulerOpts['name'], maxEvents, now, templateData, jobSchedulerId, delay)
|
|
538
|
+
elseif hasCollision then
|
|
539
|
+
-- For 'pattern' case: return error code
|
|
540
|
+
return -10 -- SchedulerJobIdCollision
|
|
541
|
+
end
|
|
535
542
|
if ARGV[9] ~= "" then
|
|
536
543
|
rcall("HSET", ARGV[9], "nrjid", jobId)
|
|
537
544
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiiBf,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|