bullmq 5.8.7 → 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/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
- package/dist/cjs/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -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/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 +39 -18
- 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/{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/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/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
- package/dist/esm/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -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/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 +39 -18
- 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/{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/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
@@ -28,14 +28,14 @@ local parentKey = ARGV[2]
|
|
28
28
|
--[[
|
29
29
|
Add marker if needed when a job is available.
|
30
30
|
]]
|
31
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
32
|
-
if not
|
31
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
32
|
+
if not isPausedOrMaxed then
|
33
33
|
rcall("ZADD", markerKey, 0, "0")
|
34
34
|
end
|
35
35
|
end
|
36
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
36
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
37
37
|
rcall(pushCmd, targetKey, jobId)
|
38
|
-
addBaseMarkerIfNeeded(markerKey,
|
38
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
39
39
|
end
|
40
40
|
--[[
|
41
41
|
Functions to destructure job key.
|
@@ -51,12 +51,21 @@ end
|
|
51
51
|
Function to check for the meta.paused key to decide if we are paused or not
|
52
52
|
(since an empty list and !EXISTS are not really the same).
|
53
53
|
]]
|
54
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
55
|
-
|
56
|
-
|
57
|
-
else
|
54
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
55
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
56
|
+
if queueAttributes[1] then
|
58
57
|
return pausedKey, true
|
58
|
+
else
|
59
|
+
if queueAttributes[2] then
|
60
|
+
local activeCount = rcall("LLEN", activeKey)
|
61
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
62
|
+
return waitKey, true
|
63
|
+
else
|
64
|
+
return waitKey, false
|
65
|
+
end
|
66
|
+
end
|
59
67
|
end
|
68
|
+
return waitKey, false
|
60
69
|
end
|
61
70
|
--[[
|
62
71
|
Function to remove job keys.
|
@@ -66,9 +75,9 @@ local function removeJobKeys(jobKey)
|
|
66
75
|
jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
|
67
76
|
end
|
68
77
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
69
|
-
local parentTarget,
|
70
|
-
parentPrefix .. "paused")
|
71
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
78
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
79
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
80
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
72
81
|
if emitEvent then
|
73
82
|
local parentEventStream = parentPrefix .. "events"
|
74
83
|
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;AACL,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -3,6 +3,7 @@ const content = `--[[
|
|
3
3
|
In order to be able to remove a job, it cannot be active.
|
4
4
|
Input:
|
5
5
|
KEYS[1] queue prefix
|
6
|
+
KEYS[2] meta key
|
6
7
|
ARGV[1] jobId
|
7
8
|
ARGV[2] remove children
|
8
9
|
Events:
|
@@ -113,30 +114,39 @@ end
|
|
113
114
|
--[[
|
114
115
|
Add marker if needed when a job is available.
|
115
116
|
]]
|
116
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
117
|
-
if not
|
117
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
118
|
+
if not isPausedOrMaxed then
|
118
119
|
rcall("ZADD", markerKey, 0, "0")
|
119
120
|
end
|
120
121
|
end
|
121
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
122
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
122
123
|
rcall(pushCmd, targetKey, jobId)
|
123
|
-
addBaseMarkerIfNeeded(markerKey,
|
124
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
124
125
|
end
|
125
126
|
--[[
|
126
127
|
Function to check for the meta.paused key to decide if we are paused or not
|
127
128
|
(since an empty list and !EXISTS are not really the same).
|
128
129
|
]]
|
129
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
130
|
-
|
131
|
-
|
132
|
-
else
|
130
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
131
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
132
|
+
if queueAttributes[1] then
|
133
133
|
return pausedKey, true
|
134
|
+
else
|
135
|
+
if queueAttributes[2] then
|
136
|
+
local activeCount = rcall("LLEN", activeKey)
|
137
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
138
|
+
return waitKey, true
|
139
|
+
else
|
140
|
+
return waitKey, false
|
141
|
+
end
|
142
|
+
end
|
134
143
|
end
|
144
|
+
return waitKey, false
|
135
145
|
end
|
136
146
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
137
|
-
local parentTarget,
|
138
|
-
parentPrefix .. "paused")
|
139
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
147
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
148
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
149
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
140
150
|
if emitEvent then
|
141
151
|
local parentEventStream = parentPrefix .. "events"
|
142
152
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -234,7 +244,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
234
244
|
end
|
235
245
|
local prev = removeJobFromAnyState(prefix, jobId)
|
236
246
|
if removeJobKeys(jobKey) > 0 then
|
237
|
-
local maxEvents = getOrSetMaxEvents(
|
247
|
+
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
238
248
|
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
239
249
|
"jobId", jobId, "prev", prev)
|
240
250
|
end
|
@@ -249,6 +259,6 @@ return 0
|
|
249
259
|
export const removeJob = {
|
250
260
|
name: 'removeJob',
|
251
261
|
content,
|
252
|
-
keys:
|
262
|
+
keys: 2,
|
253
263
|
};
|
254
|
-
//# sourceMappingURL=removeJob-
|
264
|
+
//# 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;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -7,7 +7,8 @@ const content = `--[[
|
|
7
7
|
KEYS[4] wait key
|
8
8
|
KEYS[5] meta
|
9
9
|
KEYS[6] paused key
|
10
|
-
KEYS[7]
|
10
|
+
KEYS[7] active key
|
11
|
+
KEYS[8] marker key
|
11
12
|
ARGV[1] job.id
|
12
13
|
ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
|
13
14
|
ARGV[3] propVal - failedReason/returnvalue
|
@@ -26,14 +27,14 @@ local rcall = redis.call;
|
|
26
27
|
--[[
|
27
28
|
Add marker if needed when a job is available.
|
28
29
|
]]
|
29
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
30
|
-
if not
|
30
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
31
|
+
if not isPausedOrMaxed then
|
31
32
|
rcall("ZADD", markerKey, 0, "0")
|
32
33
|
end
|
33
34
|
end
|
34
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
35
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
35
36
|
rcall(pushCmd, targetKey, jobId)
|
36
|
-
addBaseMarkerIfNeeded(markerKey,
|
37
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
37
38
|
end
|
38
39
|
--[[
|
39
40
|
Function to get max events value or set by default 10000.
|
@@ -50,19 +51,28 @@ end
|
|
50
51
|
Function to check for the meta.paused key to decide if we are paused or not
|
51
52
|
(since an empty list and !EXISTS are not really the same).
|
52
53
|
]]
|
53
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
54
|
-
|
55
|
-
|
56
|
-
else
|
54
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
55
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
56
|
+
if queueAttributes[1] then
|
57
57
|
return pausedKey, true
|
58
|
+
else
|
59
|
+
if queueAttributes[2] then
|
60
|
+
local activeCount = rcall("LLEN", activeKey)
|
61
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
62
|
+
return waitKey, true
|
63
|
+
else
|
64
|
+
return waitKey, false
|
65
|
+
end
|
66
|
+
end
|
58
67
|
end
|
68
|
+
return waitKey, false
|
59
69
|
end
|
60
70
|
if rcall("EXISTS", KEYS[1]) == 1 then
|
61
71
|
local jobId = ARGV[1]
|
62
72
|
if (rcall("ZREM", KEYS[3], jobId) == 1) then
|
63
73
|
rcall("HDEL", KEYS[1], "finishedOn", "processedOn", ARGV[3])
|
64
|
-
local target,
|
65
|
-
addJobInTargetList(target, KEYS[
|
74
|
+
local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[7], KEYS[4], KEYS[6])
|
75
|
+
addJobInTargetList(target, KEYS[8], ARGV[2], isPausedOrMaxed, jobId)
|
66
76
|
local maxEvents = getOrSetMaxEvents(KEYS[5])
|
67
77
|
-- Emit waiting event
|
68
78
|
rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "waiting",
|
@@ -78,6 +88,6 @@ end
|
|
78
88
|
export const reprocessJob = {
|
79
89
|
name: 'reprocessJob',
|
80
90
|
content,
|
81
|
-
keys:
|
91
|
+
keys: 8,
|
82
92
|
};
|
83
|
-
//# sourceMappingURL=reprocessJob-
|
93
|
+
//# 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;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -34,24 +34,25 @@ local rcall = redis.call
|
|
34
34
|
--[[
|
35
35
|
Add marker if needed when a job is available.
|
36
36
|
]]
|
37
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
38
|
-
if not
|
37
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
38
|
+
if not isPausedOrMaxed then
|
39
39
|
rcall("ZADD", markerKey, 0, "0")
|
40
40
|
end
|
41
41
|
end
|
42
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
42
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
43
43
|
rcall(pushCmd, targetKey, jobId)
|
44
|
-
addBaseMarkerIfNeeded(markerKey,
|
44
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
45
45
|
end
|
46
46
|
--[[
|
47
47
|
Function to add job considering priority.
|
48
48
|
]]
|
49
49
|
-- Includes
|
50
|
-
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
50
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
51
|
+
isPausedOrMaxed)
|
51
52
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
52
53
|
local score = priority * 0x100000000 + prioCounter % 0x100000000
|
53
54
|
rcall("ZADD", prioritizedKey, score, jobId)
|
54
|
-
addBaseMarkerIfNeeded(markerKey,
|
55
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
55
56
|
end
|
56
57
|
--[[
|
57
58
|
Function to get max events value or set by default 10000.
|
@@ -68,12 +69,21 @@ end
|
|
68
69
|
Function to check for the meta.paused key to decide if we are paused or not
|
69
70
|
(since an empty list and !EXISTS are not really the same).
|
70
71
|
]]
|
71
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
72
|
-
|
73
|
-
|
74
|
-
else
|
72
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
73
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
74
|
+
if queueAttributes[1] then
|
75
75
|
return pausedKey, true
|
76
|
+
else
|
77
|
+
if queueAttributes[2] then
|
78
|
+
local activeCount = rcall("LLEN", activeKey)
|
79
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
80
|
+
return waitKey, true
|
81
|
+
else
|
82
|
+
return waitKey, false
|
83
|
+
end
|
84
|
+
end
|
76
85
|
end
|
86
|
+
return waitKey, false
|
77
87
|
end
|
78
88
|
--[[
|
79
89
|
Updates the delay set, by moving delayed jobs that should
|
@@ -125,11 +135,27 @@ local function removeLock(jobKey, stalledKey, token, jobId)
|
|
125
135
|
end
|
126
136
|
return 0
|
127
137
|
end
|
128
|
-
|
138
|
+
--[[
|
139
|
+
Function to check if queue is paused or maxed
|
140
|
+
(since an empty list and !EXISTS are not really the same).
|
141
|
+
]]
|
142
|
+
local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
143
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
144
|
+
if queueAttributes[1] then
|
145
|
+
return true
|
146
|
+
else
|
147
|
+
if queueAttributes[2] then
|
148
|
+
local activeCount = rcall("LLEN", activeKey)
|
149
|
+
return activeCount >= tonumber(queueAttributes[2])
|
150
|
+
end
|
151
|
+
end
|
152
|
+
return false
|
153
|
+
end
|
154
|
+
local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[1], KEYS[2], KEYS[3])
|
129
155
|
local markerKey = KEYS[10]
|
130
156
|
-- Check if there are delayed jobs that we can move to wait.
|
131
157
|
-- test example: when there are delayed jobs between retries
|
132
|
-
promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[8], KEYS[6], ARGV[1], ARGV[2], KEYS[9],
|
158
|
+
promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[8], KEYS[6], ARGV[1], ARGV[2], KEYS[9], isPausedOrMaxed)
|
133
159
|
if rcall("EXISTS", KEYS[4]) == 1 then
|
134
160
|
local errorCode = removeLock(KEYS[4], KEYS[11], ARGV[5], ARGV[4])
|
135
161
|
if errorCode < 0 then
|
@@ -138,11 +164,13 @@ if rcall("EXISTS", KEYS[4]) == 1 then
|
|
138
164
|
local numRemovedElements = rcall("LREM", KEYS[1], -1, ARGV[4])
|
139
165
|
if (numRemovedElements < 1) then return -3 end
|
140
166
|
local priority = tonumber(rcall("HGET", KEYS[4], "priority")) or 0
|
167
|
+
--need to re-evaluate after removing job from active
|
168
|
+
isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[1])
|
141
169
|
-- Standard or priority add
|
142
170
|
if priority == 0 then
|
143
|
-
addJobInTargetList(target,
|
171
|
+
addJobInTargetList(target, markerKey, ARGV[3], isPausedOrMaxed, ARGV[4])
|
144
172
|
else
|
145
|
-
addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9],
|
173
|
+
addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9], isPausedOrMaxed)
|
146
174
|
end
|
147
175
|
rcall("HINCRBY", KEYS[4], "atm", 1)
|
148
176
|
local maxEvents = getOrSetMaxEvents(KEYS[5])
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"retryJob-11.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"retryJob-11.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuLf,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|