bullmq 5.8.6 → 5.9.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/queue.js +29 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.js +17 -1
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.js +1 -1
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/addDelayedJob-6.lua +2 -6
- package/dist/cjs/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
- package/dist/cjs/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
- package/dist/cjs/commands/changeDelay-4.lua +1 -5
- package/dist/cjs/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
- package/dist/cjs/commands/getCountsPerPriority-4.lua +6 -3
- package/dist/cjs/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
- package/dist/cjs/commands/includes/addJobInTargetList.lua +2 -2
- package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -2
- package/dist/cjs/commands/includes/getTargetQueueList.lua +14 -4
- package/dist/cjs/commands/includes/isQueueMaxed.lua +15 -0
- package/dist/cjs/commands/includes/isQueuePaused.lua +1 -1
- package/dist/cjs/commands/includes/isQueuePausedOrMaxed.lua +18 -0
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +3 -3
- package/dist/cjs/commands/isMaxed-2.lua +17 -0
- package/dist/cjs/commands/moveJobFromActiveToWait-10.lua +2 -2
- package/dist/{esm/commands/moveJobsToWait-7.lua → cjs/commands/moveJobsToWait-8.lua} +4 -3
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +3 -3
- package/dist/cjs/commands/moveToActive-11.lua +4 -4
- package/dist/cjs/commands/moveToDelayed-8.lua +2 -6
- package/dist/cjs/commands/moveToFinished-14.lua +4 -4
- package/dist/cjs/commands/moveToWaitingChildren-5.lua +4 -3
- package/dist/{esm/commands/promote-8.lua → cjs/commands/promote-9.lua} +9 -7
- package/dist/{esm/commands/removeJob-1.lua → cjs/commands/removeJob-2.lua} +2 -1
- package/dist/{esm/commands/reprocessJob-7.lua → cjs/commands/reprocessJob-8.lua} +4 -3
- package/dist/cjs/commands/retryJob-11.lua +8 -4
- package/dist/cjs/scripts/addDelayedJob-6.js +41 -23
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +39 -18
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -0
- package/dist/cjs/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -0
- package/dist/cjs/scripts/changeDelay-4.js +1 -11
- package/dist/cjs/scripts/changeDelay-4.js.map +1 -1
- package/dist/cjs/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
- package/dist/cjs/scripts/changePriority-7.js.map +1 -0
- package/dist/cjs/scripts/cleanJobsInSet-2.js +20 -11
- package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/cjs/scripts/drain-4.js +20 -11
- package/dist/cjs/scripts/drain-4.js.map +1 -1
- package/dist/cjs/scripts/getCountsPerPriority-4.js +7 -8
- package/dist/cjs/scripts/getCountsPerPriority-4.js.map +1 -1
- package/dist/cjs/scripts/index.js +8 -7
- package/dist/cjs/scripts/index.js.map +1 -1
- package/dist/cjs/scripts/isMaxed-2.js +34 -0
- package/dist/cjs/scripts/isMaxed-2.js.map +1 -0
- package/dist/cjs/scripts/moveJobFromActiveToWait-10.js +19 -10
- package/dist/cjs/scripts/moveJobFromActiveToWait-10.js.map +1 -1
- package/dist/cjs/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
- package/dist/cjs/scripts/moveJobsToWait-8.js.map +1 -0
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +45 -24
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToActive-11.js +24 -14
- package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
- package/dist/cjs/scripts/moveToDelayed-8.js +2 -12
- package/dist/cjs/scripts/moveToDelayed-8.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +46 -25
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-5.js +4 -3
- package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +20 -11
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/{promote-8.js → promote-9.js} +31 -19
- package/dist/cjs/scripts/promote-9.js.map +1 -0
- package/dist/cjs/scripts/removeChildDependency-1.js +20 -11
- package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/cjs/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
- package/dist/cjs/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
- package/dist/cjs/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
- package/dist/cjs/scripts/reprocessJob-8.js.map +1 -0
- package/dist/cjs/scripts/retryJob-11.js +42 -14
- package/dist/cjs/scripts/retryJob-11.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/queue.d.ts +17 -0
- package/dist/esm/classes/queue.js +29 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.d.ts +2 -0
- package/dist/esm/classes/scripts.js +17 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.js +1 -1
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/addDelayedJob-6.lua +2 -6
- package/dist/esm/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
- package/dist/esm/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
- package/dist/esm/commands/changeDelay-4.lua +1 -5
- package/dist/esm/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
- package/dist/esm/commands/getCountsPerPriority-4.lua +6 -3
- package/dist/esm/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
- package/dist/esm/commands/includes/addJobInTargetList.lua +2 -2
- package/dist/esm/commands/includes/addJobWithPriority.lua +3 -2
- package/dist/esm/commands/includes/getTargetQueueList.lua +14 -4
- package/dist/esm/commands/includes/isQueueMaxed.lua +15 -0
- package/dist/esm/commands/includes/isQueuePaused.lua +1 -1
- package/dist/esm/commands/includes/isQueuePausedOrMaxed.lua +18 -0
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +3 -3
- package/dist/esm/commands/isMaxed-2.lua +17 -0
- package/dist/esm/commands/moveJobFromActiveToWait-10.lua +2 -2
- package/dist/{cjs/commands/moveJobsToWait-7.lua → esm/commands/moveJobsToWait-8.lua} +4 -3
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +3 -3
- package/dist/esm/commands/moveToActive-11.lua +4 -4
- package/dist/esm/commands/moveToDelayed-8.lua +2 -6
- package/dist/esm/commands/moveToFinished-14.lua +4 -4
- package/dist/esm/commands/moveToWaitingChildren-5.lua +4 -3
- package/dist/{cjs/commands/promote-8.lua → esm/commands/promote-9.lua} +9 -7
- package/dist/{cjs/commands/removeJob-1.lua → esm/commands/removeJob-2.lua} +2 -1
- package/dist/{cjs/commands/reprocessJob-7.lua → esm/commands/reprocessJob-8.lua} +4 -3
- package/dist/esm/commands/retryJob-11.lua +8 -4
- package/dist/esm/scripts/addDelayedJob-6.js +41 -23
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +39 -18
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -0
- package/dist/esm/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -0
- package/dist/esm/scripts/changeDelay-4.js +1 -11
- package/dist/esm/scripts/changeDelay-4.js.map +1 -1
- package/dist/esm/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
- package/dist/esm/scripts/changePriority-7.js.map +1 -0
- package/dist/esm/scripts/cleanJobsInSet-2.js +20 -11
- package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/esm/scripts/drain-4.js +20 -11
- package/dist/esm/scripts/drain-4.js.map +1 -1
- package/dist/esm/scripts/getCountsPerPriority-4.js +7 -8
- package/dist/esm/scripts/getCountsPerPriority-4.js.map +1 -1
- package/dist/esm/scripts/index.d.ts +8 -7
- package/dist/esm/scripts/index.js +8 -7
- package/dist/esm/scripts/index.js.map +1 -1
- package/dist/esm/scripts/isMaxed-2.d.ts +5 -0
- package/dist/esm/scripts/isMaxed-2.js +31 -0
- package/dist/esm/scripts/isMaxed-2.js.map +1 -0
- package/dist/esm/scripts/moveJobFromActiveToWait-10.js +19 -10
- package/dist/esm/scripts/moveJobFromActiveToWait-10.js.map +1 -1
- package/dist/esm/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
- package/dist/esm/scripts/moveJobsToWait-8.js.map +1 -0
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +45 -24
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToActive-11.js +24 -14
- package/dist/esm/scripts/moveToActive-11.js.map +1 -1
- package/dist/esm/scripts/moveToDelayed-8.js +2 -12
- package/dist/esm/scripts/moveToDelayed-8.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +46 -25
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-5.js +4 -3
- package/dist/esm/scripts/moveToWaitingChildren-5.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +20 -11
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/{promote-8.js → promote-9.js} +31 -19
- package/dist/esm/scripts/promote-9.js.map +1 -0
- package/dist/esm/scripts/removeChildDependency-1.js +20 -11
- package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/esm/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
- package/dist/esm/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
- package/dist/esm/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
- package/dist/esm/scripts/reprocessJob-8.js.map +1 -0
- package/dist/esm/scripts/retryJob-11.js +42 -14
- package/dist/esm/scripts/retryJob-11.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/dist/cjs/scripts/addPrioritizedJob-7.js.map +0 -1
- package/dist/cjs/scripts/addStandardJob-7.js.map +0 -1
- package/dist/cjs/scripts/changePriority-6.js.map +0 -1
- package/dist/cjs/scripts/moveJobsToWait-7.js.map +0 -1
- package/dist/cjs/scripts/promote-8.js.map +0 -1
- package/dist/cjs/scripts/reprocessJob-7.js.map +0 -1
- package/dist/esm/scripts/addPrioritizedJob-7.js.map +0 -1
- package/dist/esm/scripts/addStandardJob-7.js.map +0 -1
- package/dist/esm/scripts/changePriority-6.js.map +0 -1
- package/dist/esm/scripts/moveJobsToWait-7.js.map +0 -1
- package/dist/esm/scripts/promote-8.js.map +0 -1
- package/dist/esm/scripts/reprocessJob-7.js.map +0 -1
- /package/dist/esm/scripts/{addPrioritizedJob-7.d.ts → addPrioritizedJob-8.d.ts} +0 -0
- /package/dist/esm/scripts/{addStandardJob-7.d.ts → addStandardJob-8.d.ts} +0 -0
- /package/dist/esm/scripts/{changePriority-6.d.ts → changePriority-7.d.ts} +0 -0
- /package/dist/esm/scripts/{moveJobsToWait-7.d.ts → moveJobsToWait-8.d.ts} +0 -0
- /package/dist/esm/scripts/{promote-8.d.ts → promote-9.d.ts} +0 -0
- /package/dist/esm/scripts/{removeJob-1.d.ts → removeJob-2.d.ts} +0 -0
- /package/dist/esm/scripts/{reprocessJob-7.d.ts → reprocessJob-8.d.ts} +0 -0
@@ -135,12 +135,21 @@ end
|
|
135
135
|
Function to check for the meta.paused key to decide if we are paused or not
|
136
136
|
(since an empty list and !EXISTS are not really the same).
|
137
137
|
]]
|
138
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
139
|
-
|
140
|
-
|
141
|
-
else
|
138
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
139
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
140
|
+
if queueAttributes[1] then
|
142
141
|
return pausedKey, true
|
142
|
+
else
|
143
|
+
if queueAttributes[2] then
|
144
|
+
local activeCount = rcall("LLEN", activeKey)
|
145
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
146
|
+
return waitKey, true
|
147
|
+
else
|
148
|
+
return waitKey, false
|
149
|
+
end
|
150
|
+
end
|
143
151
|
end
|
152
|
+
return waitKey, false
|
144
153
|
end
|
145
154
|
--[[
|
146
155
|
Function to move job from prioritized state to active.
|
@@ -181,31 +190,41 @@ end
|
|
181
190
|
--[[
|
182
191
|
Add marker if needed when a job is available.
|
183
192
|
]]
|
184
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
185
|
-
if not
|
193
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
194
|
+
if not isPausedOrMaxed then
|
186
195
|
rcall("ZADD", markerKey, 0, "0")
|
187
196
|
end
|
188
197
|
end
|
189
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
198
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
190
199
|
rcall(pushCmd, targetKey, jobId)
|
191
|
-
addBaseMarkerIfNeeded(markerKey,
|
200
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
192
201
|
end
|
193
202
|
--[[
|
194
203
|
Function to add job considering priority.
|
195
204
|
]]
|
196
205
|
-- Includes
|
197
|
-
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
206
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
207
|
+
isPausedOrMaxed)
|
198
208
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
199
209
|
local score = priority * 0x100000000 + prioCounter % 0x100000000
|
200
210
|
rcall("ZADD", prioritizedKey, score, jobId)
|
201
|
-
addBaseMarkerIfNeeded(markerKey,
|
211
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
202
212
|
end
|
203
213
|
--[[
|
204
|
-
Function to check
|
214
|
+
Function to check if queue is paused or maxed
|
205
215
|
(since an empty list and !EXISTS are not really the same).
|
206
216
|
]]
|
207
|
-
local function
|
208
|
-
|
217
|
+
local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
218
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
219
|
+
if queueAttributes[1] then
|
220
|
+
return true
|
221
|
+
else
|
222
|
+
if queueAttributes[2] then
|
223
|
+
local activeCount = rcall("LLEN", activeKey)
|
224
|
+
return activeCount >= tonumber(queueAttributes[2])
|
225
|
+
end
|
226
|
+
end
|
227
|
+
return false
|
209
228
|
end
|
210
229
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
211
230
|
parentKey, parentId, timestamp)
|
@@ -215,6 +234,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
215
234
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
216
235
|
local parentWaitKey = parentQueueKey .. ":wait"
|
217
236
|
local parentPausedKey = parentQueueKey .. ":paused"
|
237
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
218
238
|
local parentMetaKey = parentQueueKey .. ":meta"
|
219
239
|
local parentMarkerKey = parentQueueKey .. ":marker"
|
220
240
|
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
@@ -230,15 +250,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
230
250
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
231
251
|
else
|
232
252
|
if priority == 0 then
|
233
|
-
local parentTarget,
|
234
|
-
getTargetQueueList(parentMetaKey, parentWaitKey,
|
253
|
+
local parentTarget, isParentPausedOrMaxed =
|
254
|
+
getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
|
235
255
|
parentPausedKey)
|
236
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH",
|
256
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
|
257
|
+
parentId)
|
237
258
|
else
|
238
|
-
local
|
259
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
239
260
|
addJobWithPriority(parentMarkerKey,
|
240
261
|
parentQueueKey .. ":prioritized", priority,
|
241
|
-
parentId, parentQueueKey .. ":pc",
|
262
|
+
parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
|
242
263
|
end
|
243
264
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
244
265
|
"jobId", parentId, "prev", "waiting-children")
|
@@ -372,9 +393,9 @@ local getJobKeyPrefix = function (jobKey, jobId)
|
|
372
393
|
return string.sub(jobKey, 0, #jobKey - #jobId)
|
373
394
|
end
|
374
395
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
375
|
-
local parentTarget,
|
376
|
-
parentPrefix .. "paused")
|
377
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
396
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
397
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
398
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
378
399
|
if emitEvent then
|
379
400
|
local parentEventStream = parentPrefix .. "events"
|
380
401
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -621,16 +642,16 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
621
642
|
-- Try to get next job to avoid an extra roundtrip if the queue is not closing,
|
622
643
|
-- and not rate limited.
|
623
644
|
if (ARGV[6] == "1") then
|
624
|
-
local target,
|
645
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])
|
625
646
|
-- Check if there are delayed jobs that can be promoted
|
626
647
|
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, ARGV[7],
|
627
|
-
timestamp, KEYS[10],
|
648
|
+
timestamp, KEYS[10], isPausedOrMaxed)
|
628
649
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
629
650
|
-- Check if we are rate limited first.
|
630
651
|
local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
|
631
652
|
if expireTime > 0 then return {0, 0, expireTime, 0} end
|
632
|
-
-- paused queue
|
633
|
-
if
|
653
|
+
-- paused or maxed queue
|
654
|
+
if isPausedOrMaxed then return {0, 0, 0, 0} end
|
634
655
|
jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
|
635
656
|
if jobId then
|
636
657
|
-- Markers in waitlist DEPRECATED in v5: Remove in v6.
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4rBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -21,7 +21,8 @@ const content = `--[[
|
|
21
21
|
-3 - Job not in active set
|
22
22
|
]]
|
23
23
|
local rcall = redis.call
|
24
|
-
|
24
|
+
local stalledKey = KEYS[5]
|
25
|
+
--- Includes
|
25
26
|
local function removeLock(jobKey, stalledKey, token, jobId)
|
26
27
|
if token ~= "0" then
|
27
28
|
local lockKey = jobKey .. ':lock'
|
@@ -54,7 +55,7 @@ end
|
|
54
55
|
if rcall("EXISTS", KEYS[4]) == 1 then
|
55
56
|
if ARGV[2] ~= "" then
|
56
57
|
if rcall("SISMEMBER", KEYS[4] .. ":dependencies", ARGV[2]) ~= 0 then
|
57
|
-
local errorCode = removeLock(KEYS[4],
|
58
|
+
local errorCode = removeLock(KEYS[4], stalledKey, ARGV[1], ARGV[4])
|
58
59
|
if errorCode < 0 then
|
59
60
|
return errorCode
|
60
61
|
end
|
@@ -63,7 +64,7 @@ if rcall("EXISTS", KEYS[4]) == 1 then
|
|
63
64
|
return 1
|
64
65
|
else
|
65
66
|
if rcall("SCARD", KEYS[4] .. ":dependencies") ~= 0 then
|
66
|
-
local errorCode = removeLock(KEYS[4],
|
67
|
+
local errorCode = removeLock(KEYS[4], stalledKey, ARGV[1], ARGV[4])
|
67
68
|
if errorCode < 0 then
|
68
69
|
return errorCode
|
69
70
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToWaitingChildren-5.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-5.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToWaitingChildren-5.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-5.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEf,CAAC;AACW,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -47,14 +47,14 @@ end
|
|
47
47
|
--[[
|
48
48
|
Add marker if needed when a job is available.
|
49
49
|
]]
|
50
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
51
|
-
if not
|
50
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
51
|
+
if not isPausedOrMaxed then
|
52
52
|
rcall("ZADD", markerKey, 0, "0")
|
53
53
|
end
|
54
54
|
end
|
55
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
55
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
56
56
|
rcall(pushCmd, targetKey, jobId)
|
57
|
-
addBaseMarkerIfNeeded(markerKey,
|
57
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
58
58
|
end
|
59
59
|
--[[
|
60
60
|
Functions to destructure job key.
|
@@ -70,17 +70,26 @@ end
|
|
70
70
|
Function to check for the meta.paused key to decide if we are paused or not
|
71
71
|
(since an empty list and !EXISTS are not really the same).
|
72
72
|
]]
|
73
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
74
|
-
|
75
|
-
|
76
|
-
else
|
73
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
74
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
75
|
+
if queueAttributes[1] then
|
77
76
|
return pausedKey, true
|
77
|
+
else
|
78
|
+
if queueAttributes[2] then
|
79
|
+
local activeCount = rcall("LLEN", activeKey)
|
80
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
81
|
+
return waitKey, true
|
82
|
+
else
|
83
|
+
return waitKey, false
|
84
|
+
end
|
85
|
+
end
|
78
86
|
end
|
87
|
+
return waitKey, false
|
79
88
|
end
|
80
89
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
81
|
-
local parentTarget,
|
82
|
-
parentPrefix .. "paused")
|
83
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
90
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
91
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
92
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
84
93
|
if emitEvent then
|
85
94
|
local parentEventStream = parentPrefix .. "events"
|
86
95
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiRf,CAAC;AACW,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -9,9 +9,10 @@ const content = `--[[
|
|
9
9
|
KEYS[3] 'paused'
|
10
10
|
KEYS[4] 'meta'
|
11
11
|
KEYS[5] 'prioritized'
|
12
|
-
KEYS[6] '
|
13
|
-
KEYS[7] '
|
14
|
-
KEYS[8] '
|
12
|
+
KEYS[6] 'active'
|
13
|
+
KEYS[7] 'pc' priority counter
|
14
|
+
KEYS[8] 'event stream'
|
15
|
+
KEYS[9] 'marker'
|
15
16
|
ARGV[1] queue.toKey('')
|
16
17
|
ARGV[2] jobId
|
17
18
|
Output:
|
@@ -30,54 +31,65 @@ local jobId = ARGV[2]
|
|
30
31
|
--[[
|
31
32
|
Add marker if needed when a job is available.
|
32
33
|
]]
|
33
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
34
|
-
if not
|
34
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
35
|
+
if not isPausedOrMaxed then
|
35
36
|
rcall("ZADD", markerKey, 0, "0")
|
36
37
|
end
|
37
38
|
end
|
38
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
39
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
39
40
|
rcall(pushCmd, targetKey, jobId)
|
40
|
-
addBaseMarkerIfNeeded(markerKey,
|
41
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
41
42
|
end
|
42
43
|
--[[
|
43
44
|
Function to add job considering priority.
|
44
45
|
]]
|
45
46
|
-- Includes
|
46
|
-
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
47
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
48
|
+
isPausedOrMaxed)
|
47
49
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
48
50
|
local score = priority * 0x100000000 + prioCounter % 0x100000000
|
49
51
|
rcall("ZADD", prioritizedKey, score, jobId)
|
50
|
-
addBaseMarkerIfNeeded(markerKey,
|
52
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
51
53
|
end
|
52
54
|
--[[
|
53
55
|
Function to check for the meta.paused key to decide if we are paused or not
|
54
56
|
(since an empty list and !EXISTS are not really the same).
|
55
57
|
]]
|
56
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
57
|
-
|
58
|
-
|
59
|
-
else
|
58
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
59
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
60
|
+
if queueAttributes[1] then
|
60
61
|
return pausedKey, true
|
62
|
+
else
|
63
|
+
if queueAttributes[2] then
|
64
|
+
local activeCount = rcall("LLEN", activeKey)
|
65
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
66
|
+
return waitKey, true
|
67
|
+
else
|
68
|
+
return waitKey, false
|
69
|
+
end
|
70
|
+
end
|
61
71
|
end
|
72
|
+
return waitKey, false
|
62
73
|
end
|
63
74
|
if rcall("ZREM", KEYS[1], jobId) == 1 then
|
64
75
|
local jobKey = ARGV[1] .. jobId
|
65
76
|
local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0
|
66
77
|
local metaKey = KEYS[4]
|
78
|
+
local markerKey = KEYS[9]
|
67
79
|
-- Remove delayed "marker" from the wait list if there is any.
|
68
80
|
-- Since we are adding a job we do not need the marker anymore.
|
69
81
|
-- Markers in waitlist DEPRECATED in v5: Remove in v6.
|
70
|
-
local target,
|
82
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[6], KEYS[2], KEYS[3])
|
71
83
|
local marker = rcall("LINDEX", target, 0)
|
72
84
|
if marker and string.sub(marker, 1, 2) == "0:" then rcall("LPOP", target) end
|
73
85
|
if priority == 0 then
|
74
86
|
-- LIFO or FIFO
|
75
|
-
addJobInTargetList(target,
|
87
|
+
addJobInTargetList(target, markerKey, "LPUSH", isPausedOrMaxed, jobId)
|
76
88
|
else
|
77
|
-
addJobWithPriority(
|
89
|
+
addJobWithPriority(markerKey, KEYS[5], priority, jobId, KEYS[7], isPausedOrMaxed)
|
78
90
|
end
|
79
91
|
-- Emit waiting event (wait..ing@token)
|
80
|
-
rcall("XADD", KEYS[
|
92
|
+
rcall("XADD", KEYS[8], "*", "event", "waiting", "jobId", jobId, "prev",
|
81
93
|
"delayed");
|
82
94
|
rcall("HSET", jobKey, "delay", 0)
|
83
95
|
return 0
|
@@ -88,6 +100,6 @@ end
|
|
88
100
|
exports.promote = {
|
89
101
|
name: 'promote',
|
90
102
|
content,
|
91
|
-
keys:
|
103
|
+
keys: 9,
|
92
104
|
};
|
93
|
-
//# sourceMappingURL=promote-
|
105
|
+
//# sourceMappingURL=promote-9.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"promote-9.js","sourceRoot":"","sources":["../../../src/scripts/promote-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Ff,CAAC;AACW,QAAA,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -31,14 +31,14 @@ local parentKey = ARGV[2]
|
|
31
31
|
--[[
|
32
32
|
Add marker if needed when a job is available.
|
33
33
|
]]
|
34
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
35
|
-
if not
|
34
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
35
|
+
if not isPausedOrMaxed then
|
36
36
|
rcall("ZADD", markerKey, 0, "0")
|
37
37
|
end
|
38
38
|
end
|
39
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
39
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
40
40
|
rcall(pushCmd, targetKey, jobId)
|
41
|
-
addBaseMarkerIfNeeded(markerKey,
|
41
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
42
42
|
end
|
43
43
|
--[[
|
44
44
|
Functions to destructure job key.
|
@@ -54,12 +54,21 @@ end
|
|
54
54
|
Function to check for the meta.paused key to decide if we are paused or not
|
55
55
|
(since an empty list and !EXISTS are not really the same).
|
56
56
|
]]
|
57
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
58
|
-
|
59
|
-
|
60
|
-
else
|
57
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
58
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
59
|
+
if queueAttributes[1] then
|
61
60
|
return pausedKey, true
|
61
|
+
else
|
62
|
+
if queueAttributes[2] then
|
63
|
+
local activeCount = rcall("LLEN", activeKey)
|
64
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
65
|
+
return waitKey, true
|
66
|
+
else
|
67
|
+
return waitKey, false
|
68
|
+
end
|
69
|
+
end
|
62
70
|
end
|
71
|
+
return waitKey, false
|
63
72
|
end
|
64
73
|
--[[
|
65
74
|
Function to remove job keys.
|
@@ -69,9 +78,9 @@ local function removeJobKeys(jobKey)
|
|
69
78
|
jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
|
70
79
|
end
|
71
80
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
72
|
-
local parentTarget,
|
73
|
-
parentPrefix .. "paused")
|
74
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
81
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
82
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
83
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
75
84
|
if emitEvent then
|
76
85
|
local parentEventStream = parentPrefix .. "events"
|
77
86
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoJZ,CAAC;AACQ,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -6,6 +6,7 @@ const content = `--[[
|
|
6
6
|
In order to be able to remove a job, it cannot be active.
|
7
7
|
Input:
|
8
8
|
KEYS[1] queue prefix
|
9
|
+
KEYS[2] meta key
|
9
10
|
ARGV[1] jobId
|
10
11
|
ARGV[2] remove children
|
11
12
|
Events:
|
@@ -116,30 +117,39 @@ end
|
|
116
117
|
--[[
|
117
118
|
Add marker if needed when a job is available.
|
118
119
|
]]
|
119
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
120
|
-
if not
|
120
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
121
|
+
if not isPausedOrMaxed then
|
121
122
|
rcall("ZADD", markerKey, 0, "0")
|
122
123
|
end
|
123
124
|
end
|
124
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
125
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
125
126
|
rcall(pushCmd, targetKey, jobId)
|
126
|
-
addBaseMarkerIfNeeded(markerKey,
|
127
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
127
128
|
end
|
128
129
|
--[[
|
129
130
|
Function to check for the meta.paused key to decide if we are paused or not
|
130
131
|
(since an empty list and !EXISTS are not really the same).
|
131
132
|
]]
|
132
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
133
|
-
|
134
|
-
|
135
|
-
else
|
133
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
134
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
135
|
+
if queueAttributes[1] then
|
136
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
|
137
146
|
end
|
147
|
+
return waitKey, false
|
138
148
|
end
|
139
149
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
140
|
-
local parentTarget,
|
141
|
-
parentPrefix .. "paused")
|
142
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
150
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
151
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
152
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
143
153
|
if emitEvent then
|
144
154
|
local parentEventStream = parentPrefix .. "events"
|
145
155
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -237,7 +247,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
237
247
|
end
|
238
248
|
local prev = removeJobFromAnyState(prefix, jobId)
|
239
249
|
if removeJobKeys(jobKey) > 0 then
|
240
|
-
local maxEvents = getOrSetMaxEvents(
|
250
|
+
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
241
251
|
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
242
252
|
"jobId", jobId, "prev", prev)
|
243
253
|
end
|
@@ -252,6 +262,6 @@ return 0
|
|
252
262
|
exports.removeJob = {
|
253
263
|
name: 'removeJob',
|
254
264
|
content,
|
255
|
-
keys:
|
265
|
+
keys: 2,
|
256
266
|
};
|
257
|
-
//# sourceMappingURL=removeJob-
|
267
|
+
//# sourceMappingURL=removeJob-2.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"removeJob-
|
1
|
+
{"version":3,"file":"removeJob-2.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiQf,CAAC;AACW,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -10,7 +10,8 @@ const content = `--[[
|
|
10
10
|
KEYS[4] wait key
|
11
11
|
KEYS[5] meta
|
12
12
|
KEYS[6] paused key
|
13
|
-
KEYS[7]
|
13
|
+
KEYS[7] active key
|
14
|
+
KEYS[8] marker key
|
14
15
|
ARGV[1] job.id
|
15
16
|
ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
|
16
17
|
ARGV[3] propVal - failedReason/returnvalue
|
@@ -29,14 +30,14 @@ local rcall = redis.call;
|
|
29
30
|
--[[
|
30
31
|
Add marker if needed when a job is available.
|
31
32
|
]]
|
32
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
33
|
-
if not
|
33
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
34
|
+
if not isPausedOrMaxed then
|
34
35
|
rcall("ZADD", markerKey, 0, "0")
|
35
36
|
end
|
36
37
|
end
|
37
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
38
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
38
39
|
rcall(pushCmd, targetKey, jobId)
|
39
|
-
addBaseMarkerIfNeeded(markerKey,
|
40
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
40
41
|
end
|
41
42
|
--[[
|
42
43
|
Function to get max events value or set by default 10000.
|
@@ -53,19 +54,28 @@ end
|
|
53
54
|
Function to check for the meta.paused key to decide if we are paused or not
|
54
55
|
(since an empty list and !EXISTS are not really the same).
|
55
56
|
]]
|
56
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
57
|
-
|
58
|
-
|
59
|
-
else
|
57
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
58
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
59
|
+
if queueAttributes[1] then
|
60
60
|
return pausedKey, true
|
61
|
+
else
|
62
|
+
if queueAttributes[2] then
|
63
|
+
local activeCount = rcall("LLEN", activeKey)
|
64
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
65
|
+
return waitKey, true
|
66
|
+
else
|
67
|
+
return waitKey, false
|
68
|
+
end
|
69
|
+
end
|
61
70
|
end
|
71
|
+
return waitKey, false
|
62
72
|
end
|
63
73
|
if rcall("EXISTS", KEYS[1]) == 1 then
|
64
74
|
local jobId = ARGV[1]
|
65
75
|
if (rcall("ZREM", KEYS[3], jobId) == 1) then
|
66
76
|
rcall("HDEL", KEYS[1], "finishedOn", "processedOn", ARGV[3])
|
67
|
-
local target,
|
68
|
-
addJobInTargetList(target, KEYS[
|
77
|
+
local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[7], KEYS[4], KEYS[6])
|
78
|
+
addJobInTargetList(target, KEYS[8], ARGV[2], isPausedOrMaxed, jobId)
|
69
79
|
local maxEvents = getOrSetMaxEvents(KEYS[5])
|
70
80
|
-- Emit waiting event
|
71
81
|
rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "waiting",
|
@@ -81,6 +91,6 @@ end
|
|
81
91
|
exports.reprocessJob = {
|
82
92
|
name: 'reprocessJob',
|
83
93
|
content,
|
84
|
-
keys:
|
94
|
+
keys: 8,
|
85
95
|
};
|
86
|
-
//# sourceMappingURL=reprocessJob-
|
96
|
+
//# sourceMappingURL=reprocessJob-8.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"reprocessJob-8.js","sourceRoot":"","sources":["../../../src/scripts/reprocessJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|