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
@@ -45,14 +45,14 @@ end
|
|
45
45
|
--[[
|
46
46
|
Add marker if needed when a job is available.
|
47
47
|
]]
|
48
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
49
|
-
if not
|
48
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
49
|
+
if not isPausedOrMaxed then
|
50
50
|
rcall("ZADD", markerKey, 0, "0")
|
51
51
|
end
|
52
52
|
end
|
53
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
53
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
54
54
|
rcall(pushCmd, targetKey, jobId)
|
55
|
-
addBaseMarkerIfNeeded(markerKey,
|
55
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
56
56
|
end
|
57
57
|
--[[
|
58
58
|
Functions to destructure job key.
|
@@ -68,17 +68,26 @@ end
|
|
68
68
|
Function to check for the meta.paused key to decide if we are paused or not
|
69
69
|
(since an empty list and !EXISTS are not really the same).
|
70
70
|
]]
|
71
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
72
|
-
|
73
|
-
|
74
|
-
else
|
71
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
72
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
73
|
+
if queueAttributes[1] then
|
75
74
|
return pausedKey, true
|
75
|
+
else
|
76
|
+
if queueAttributes[2] then
|
77
|
+
local activeCount = rcall("LLEN", activeKey)
|
78
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
79
|
+
return waitKey, true
|
80
|
+
else
|
81
|
+
return waitKey, false
|
82
|
+
end
|
83
|
+
end
|
76
84
|
end
|
85
|
+
return waitKey, false
|
77
86
|
end
|
78
87
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
79
|
-
local parentTarget,
|
80
|
-
parentPrefix .. "paused")
|
81
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
88
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
89
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
90
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
82
91
|
if emitEvent then
|
83
92
|
local parentEventStream = parentPrefix .. "events"
|
84
93
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Mf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -20,18 +20,17 @@ local prioritizedKey = KEYS[4]
|
|
20
20
|
Function to check for the meta.paused key to decide if we are paused or not
|
21
21
|
(since an empty list and !EXISTS are not really the same).
|
22
22
|
]]
|
23
|
-
local function
|
24
|
-
|
25
|
-
return waitKey, false
|
26
|
-
else
|
27
|
-
return pausedKey, true
|
28
|
-
end
|
23
|
+
local function isQueuePaused(queueMetaKey)
|
24
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
29
25
|
end
|
30
26
|
for i = 1, #ARGV do
|
31
27
|
local priority = tonumber(ARGV[i])
|
32
28
|
if priority == 0 then
|
33
|
-
|
34
|
-
|
29
|
+
if isQueuePaused(KEYS[3]) then
|
30
|
+
results[#results+1] = rcall("LLEN", pausedKey)
|
31
|
+
else
|
32
|
+
results[#results+1] = rcall("LLEN", waitKey)
|
33
|
+
end
|
35
34
|
else
|
36
35
|
results[#results+1] = rcall("ZCOUNT", prioritizedKey,
|
37
36
|
priority * 0x100000000, (priority + 1) * 0x100000000 - 1)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getCountsPerPriority-4.js","sourceRoot":"","sources":["../../../src/scripts/getCountsPerPriority-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"getCountsPerPriority-4.js","sourceRoot":"","sources":["../../../src/scripts/getCountsPerPriority-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCf,CAAC;AACW,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,sBAAsB;IAC5B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -4,10 +4,10 @@ const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./addDelayedJob-6"), exports);
|
5
5
|
tslib_1.__exportStar(require("./addLog-2"), exports);
|
6
6
|
tslib_1.__exportStar(require("./addParentJob-4"), exports);
|
7
|
-
tslib_1.__exportStar(require("./addPrioritizedJob-
|
8
|
-
tslib_1.__exportStar(require("./addStandardJob-
|
7
|
+
tslib_1.__exportStar(require("./addPrioritizedJob-8"), exports);
|
8
|
+
tslib_1.__exportStar(require("./addStandardJob-8"), exports);
|
9
9
|
tslib_1.__exportStar(require("./changeDelay-4"), exports);
|
10
|
-
tslib_1.__exportStar(require("./changePriority-
|
10
|
+
tslib_1.__exportStar(require("./changePriority-7"), exports);
|
11
11
|
tslib_1.__exportStar(require("./cleanJobsInSet-2"), exports);
|
12
12
|
tslib_1.__exportStar(require("./drain-4"), exports);
|
13
13
|
tslib_1.__exportStar(require("./extendLock-2"), exports);
|
@@ -19,8 +19,9 @@ tslib_1.__exportStar(require("./getState-8"), exports);
|
|
19
19
|
tslib_1.__exportStar(require("./getStateV2-8"), exports);
|
20
20
|
tslib_1.__exportStar(require("./isFinished-3"), exports);
|
21
21
|
tslib_1.__exportStar(require("./isJobInList-1"), exports);
|
22
|
+
tslib_1.__exportStar(require("./isMaxed-2"), exports);
|
22
23
|
tslib_1.__exportStar(require("./moveJobFromActiveToWait-10"), exports);
|
23
|
-
tslib_1.__exportStar(require("./moveJobsToWait-
|
24
|
+
tslib_1.__exportStar(require("./moveJobsToWait-8"), exports);
|
24
25
|
tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
|
25
26
|
tslib_1.__exportStar(require("./moveToActive-11"), exports);
|
26
27
|
tslib_1.__exportStar(require("./moveToDelayed-8"), exports);
|
@@ -29,12 +30,12 @@ tslib_1.__exportStar(require("./moveToWaitingChildren-5"), exports);
|
|
29
30
|
tslib_1.__exportStar(require("./obliterate-2"), exports);
|
30
31
|
tslib_1.__exportStar(require("./paginate-1"), exports);
|
31
32
|
tslib_1.__exportStar(require("./pause-7"), exports);
|
32
|
-
tslib_1.__exportStar(require("./promote-
|
33
|
+
tslib_1.__exportStar(require("./promote-9"), exports);
|
33
34
|
tslib_1.__exportStar(require("./releaseLock-1"), exports);
|
34
35
|
tslib_1.__exportStar(require("./removeChildDependency-1"), exports);
|
35
|
-
tslib_1.__exportStar(require("./removeJob-
|
36
|
+
tslib_1.__exportStar(require("./removeJob-2"), exports);
|
36
37
|
tslib_1.__exportStar(require("./removeRepeatable-2"), exports);
|
37
|
-
tslib_1.__exportStar(require("./reprocessJob-
|
38
|
+
tslib_1.__exportStar(require("./reprocessJob-8"), exports);
|
38
39
|
tslib_1.__exportStar(require("./retryJob-11"), exports);
|
39
40
|
tslib_1.__exportStar(require("./saveStacktrace-1"), exports);
|
40
41
|
tslib_1.__exportStar(require("./updateData-1"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,qDAA2B;AAC3B,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,0DAAgC;AAChC,6DAAmC;AACnC,6DAAmC;AACnC,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,mEAAyC;AACzC,wDAA8B;AAC9B,8DAAoC;AACpC,uDAA6B;AAC7B,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,uEAA6C;AAC7C,6DAAmC;AACnC,oEAA0C;AAC1C,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,oEAA0C;AAC1C,yDAA+B;AAC/B,uDAA6B;AAC7B,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,oEAA0C;AAC1C,wDAA8B;AAC9B,+DAAqC;AACrC,2DAAiC;AACjC,wDAA8B;AAC9B,6DAAmC;AACnC,yDAA+B;AAC/B,6DAAmC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,qDAA2B;AAC3B,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,0DAAgC;AAChC,6DAAmC;AACnC,6DAAmC;AACnC,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,mEAAyC;AACzC,wDAA8B;AAC9B,8DAAoC;AACpC,uDAA6B;AAC7B,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,sDAA4B;AAC5B,uEAA6C;AAC7C,6DAAmC;AACnC,oEAA0C;AAC1C,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,oEAA0C;AAC1C,yDAA+B;AAC/B,uDAA6B;AAC7B,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,oEAA0C;AAC1C,wDAA8B;AAC9B,+DAAqC;AACrC,2DAAiC;AACjC,wDAA8B;AAC9B,6DAAmC;AACnC,yDAA+B;AAC/B,6DAAmC"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isMaxed = void 0;
|
4
|
+
const content = `--[[
|
5
|
+
Checks if queue is maxed.
|
6
|
+
Input:
|
7
|
+
KEYS[1] meta key
|
8
|
+
KEYS[2] active key
|
9
|
+
Output:
|
10
|
+
1 if element found in the list.
|
11
|
+
]]
|
12
|
+
local rcall = redis.call
|
13
|
+
-- Includes
|
14
|
+
--[[
|
15
|
+
Function to check if queue is maxed or not.
|
16
|
+
]]
|
17
|
+
local function isQueueMaxed(queueMetaKey, activeKey)
|
18
|
+
local maxConcurrency = rcall("HGET", queueMetaKey, "concurrency")
|
19
|
+
if maxConcurrency then
|
20
|
+
local activeCount = rcall("LLEN", activeKey)
|
21
|
+
if activeCount >= tonumber(maxConcurrency) then
|
22
|
+
return true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
return isQueueMaxed(KEYS[1], KEYS[2])
|
28
|
+
`;
|
29
|
+
exports.isMaxed = {
|
30
|
+
name: 'isMaxed',
|
31
|
+
content,
|
32
|
+
keys: 2,
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=isMaxed-2.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isMaxed-2.js","sourceRoot":"","sources":["../../../src/scripts/isMaxed-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBf,CAAC;AACW,QAAA,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -27,14 +27,14 @@ local rcall = redis.call
|
|
27
27
|
--[[
|
28
28
|
Add marker if needed when a job is available.
|
29
29
|
]]
|
30
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
31
|
-
if not
|
30
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
31
|
+
if not isPausedOrMaxed then
|
32
32
|
rcall("ZADD", markerKey, 0, "0")
|
33
33
|
end
|
34
34
|
end
|
35
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
35
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
36
36
|
rcall(pushCmd, targetKey, jobId)
|
37
|
-
addBaseMarkerIfNeeded(markerKey,
|
37
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
38
38
|
end
|
39
39
|
--[[
|
40
40
|
Function to push back job considering priority in front of same prioritized jobs.
|
@@ -60,12 +60,21 @@ end
|
|
60
60
|
Function to check for the meta.paused key to decide if we are paused or not
|
61
61
|
(since an empty list and !EXISTS are not really the same).
|
62
62
|
]]
|
63
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
64
|
-
|
65
|
-
|
66
|
-
else
|
63
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
64
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
65
|
+
if queueAttributes[1] then
|
67
66
|
return pausedKey, true
|
67
|
+
else
|
68
|
+
if queueAttributes[2] then
|
69
|
+
local activeCount = rcall("LLEN", activeKey)
|
70
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
71
|
+
return waitKey, true
|
72
|
+
else
|
73
|
+
return waitKey, false
|
74
|
+
end
|
75
|
+
end
|
68
76
|
end
|
77
|
+
return waitKey, false
|
69
78
|
end
|
70
79
|
local jobId = ARGV[1]
|
71
80
|
local token = ARGV[2]
|
@@ -76,13 +85,13 @@ if lockToken == token then
|
|
76
85
|
local metaKey = KEYS[6]
|
77
86
|
local removed = rcall("LREM", KEYS[1], 1, jobId)
|
78
87
|
if removed > 0 then
|
79
|
-
local target,
|
88
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[5])
|
80
89
|
rcall("SREM", KEYS[3], jobId)
|
81
90
|
local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0
|
82
91
|
if priority > 0 then
|
83
92
|
pushBackJobWithPriority(KEYS[8], priority, jobId)
|
84
93
|
else
|
85
|
-
addJobInTargetList(target, KEYS[9], "RPUSH",
|
94
|
+
addJobInTargetList(target, KEYS[9], "RPUSH", isPausedOrMaxed, jobId)
|
86
95
|
end
|
87
96
|
rcall("DEL", lockKey)
|
88
97
|
local maxEvents = getOrSetMaxEvents(metaKey)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveJobFromActiveToWait-10.js","sourceRoot":"","sources":["../../../src/scripts/moveJobFromActiveToWait-10.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveJobFromActiveToWait-10.js","sourceRoot":"","sources":["../../../src/scripts/moveJobFromActiveToWait-10.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGf,CAAC;AACW,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -11,7 +11,8 @@ const content = `--[[
|
|
11
11
|
KEYS[4] 'wait'
|
12
12
|
KEYS[5] 'paused'
|
13
13
|
KEYS[6] 'meta'
|
14
|
-
KEYS[7] '
|
14
|
+
KEYS[7] 'active'
|
15
|
+
KEYS[8] 'marker'
|
15
16
|
ARGV[1] count
|
16
17
|
ARGV[2] timestamp
|
17
18
|
ARGV[3] prev state
|
@@ -26,8 +27,8 @@ 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
|
@@ -62,15 +63,24 @@ end
|
|
62
63
|
Function to check for the meta.paused key to decide if we are paused or not
|
63
64
|
(since an empty list and !EXISTS are not really the same).
|
64
65
|
]]
|
65
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
66
|
-
|
67
|
-
|
68
|
-
else
|
66
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
67
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
68
|
+
if queueAttributes[1] then
|
69
69
|
return pausedKey, true
|
70
|
+
else
|
71
|
+
if queueAttributes[2] then
|
72
|
+
local activeCount = rcall("LLEN", activeKey)
|
73
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
74
|
+
return waitKey, true
|
75
|
+
else
|
76
|
+
return waitKey, false
|
77
|
+
end
|
78
|
+
end
|
70
79
|
end
|
80
|
+
return waitKey, false
|
71
81
|
end
|
72
82
|
local metaKey = KEYS[6]
|
73
|
-
local target,
|
83
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])
|
74
84
|
local jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)
|
75
85
|
if (#jobs > 0) then
|
76
86
|
if ARGV[3] == "failed" then
|
@@ -94,7 +104,7 @@ if (#jobs > 0) then
|
|
94
104
|
rcall("ZREM", KEYS[3], unpack(jobs, from, to))
|
95
105
|
rcall("LPUSH", target, unpack(jobs, from, to))
|
96
106
|
end
|
97
|
-
addBaseMarkerIfNeeded(KEYS[
|
107
|
+
addBaseMarkerIfNeeded(KEYS[8], isPausedOrMaxed)
|
98
108
|
end
|
99
109
|
maxCount = maxCount - #jobs
|
100
110
|
if (maxCount <= 0) then return 1 end
|
@@ -103,6 +113,6 @@ return 0
|
|
103
113
|
exports.moveJobsToWait = {
|
104
114
|
name: 'moveJobsToWait',
|
105
115
|
content,
|
106
|
-
keys:
|
116
|
+
keys: 8,
|
107
117
|
};
|
108
|
-
//# sourceMappingURL=moveJobsToWait-
|
118
|
+
//# sourceMappingURL=moveJobsToWait-8.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"moveJobsToWait-8.js","sourceRoot":"","sources":["../../../src/scripts/moveJobsToWait-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Gf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -29,14 +29,14 @@ local rcall = redis.call
|
|
29
29
|
--[[
|
30
30
|
Add marker if needed when a job is available.
|
31
31
|
]]
|
32
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
33
|
-
if not
|
32
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
33
|
+
if not isPausedOrMaxed then
|
34
34
|
rcall("ZADD", markerKey, 0, "0")
|
35
35
|
end
|
36
36
|
end
|
37
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
37
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
38
38
|
rcall(pushCmd, targetKey, jobId)
|
39
|
-
addBaseMarkerIfNeeded(markerKey,
|
39
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
40
40
|
end
|
41
41
|
--[[
|
42
42
|
Function to loop in batches.
|
@@ -58,12 +58,21 @@ end
|
|
58
58
|
Function to check for the meta.paused key to decide if we are paused or not
|
59
59
|
(since an empty list and !EXISTS are not really the same).
|
60
60
|
]]
|
61
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
62
|
-
|
63
|
-
|
64
|
-
else
|
61
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
62
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
63
|
+
if queueAttributes[1] then
|
65
64
|
return pausedKey, true
|
65
|
+
else
|
66
|
+
if queueAttributes[2] then
|
67
|
+
local activeCount = rcall("LLEN", activeKey)
|
68
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
69
|
+
return waitKey, true
|
70
|
+
else
|
71
|
+
return waitKey, false
|
72
|
+
end
|
73
|
+
end
|
66
74
|
end
|
75
|
+
return waitKey, false
|
67
76
|
end
|
68
77
|
--[[
|
69
78
|
Function to recursively move from waitingChildren to failed.
|
@@ -101,18 +110,28 @@ end
|
|
101
110
|
Function to add job considering priority.
|
102
111
|
]]
|
103
112
|
-- Includes
|
104
|
-
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
113
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
114
|
+
isPausedOrMaxed)
|
105
115
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
106
116
|
local score = priority * 0x100000000 + prioCounter % 0x100000000
|
107
117
|
rcall("ZADD", prioritizedKey, score, jobId)
|
108
|
-
addBaseMarkerIfNeeded(markerKey,
|
118
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
109
119
|
end
|
110
120
|
--[[
|
111
|
-
Function to check
|
121
|
+
Function to check if queue is paused or maxed
|
112
122
|
(since an empty list and !EXISTS are not really the same).
|
113
123
|
]]
|
114
|
-
local function
|
115
|
-
|
124
|
+
local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
125
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
126
|
+
if queueAttributes[1] then
|
127
|
+
return true
|
128
|
+
else
|
129
|
+
if queueAttributes[2] then
|
130
|
+
local activeCount = rcall("LLEN", activeKey)
|
131
|
+
return activeCount >= tonumber(queueAttributes[2])
|
132
|
+
end
|
133
|
+
end
|
134
|
+
return false
|
116
135
|
end
|
117
136
|
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
118
137
|
parentKey, parentId, timestamp)
|
@@ -122,6 +141,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
122
141
|
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
123
142
|
local parentWaitKey = parentQueueKey .. ":wait"
|
124
143
|
local parentPausedKey = parentQueueKey .. ":paused"
|
144
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
125
145
|
local parentMetaKey = parentQueueKey .. ":meta"
|
126
146
|
local parentMarkerKey = parentQueueKey .. ":marker"
|
127
147
|
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
@@ -137,15 +157,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
137
157
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
138
158
|
else
|
139
159
|
if priority == 0 then
|
140
|
-
local parentTarget,
|
141
|
-
getTargetQueueList(parentMetaKey, parentWaitKey,
|
160
|
+
local parentTarget, isParentPausedOrMaxed =
|
161
|
+
getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
|
142
162
|
parentPausedKey)
|
143
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH",
|
163
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
|
164
|
+
parentId)
|
144
165
|
else
|
145
|
-
local
|
166
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
146
167
|
addJobWithPriority(parentMarkerKey,
|
147
168
|
parentQueueKey .. ":prioritized", priority,
|
148
|
-
parentId, parentQueueKey .. ":pc",
|
169
|
+
parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
|
149
170
|
end
|
150
171
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
151
172
|
"jobId", parentId, "prev", "waiting-children")
|
@@ -209,9 +230,9 @@ local getJobKeyPrefix = function (jobKey, jobId)
|
|
209
230
|
return string.sub(jobKey, 0, #jobKey - #jobId)
|
210
231
|
end
|
211
232
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
212
|
-
local parentTarget,
|
213
|
-
parentPrefix .. "paused")
|
214
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
233
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
234
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
235
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
215
236
|
if emitEvent then
|
216
237
|
local parentEventStream = parentPrefix .. "events"
|
217
238
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -421,10 +442,10 @@ if (#stalling > 0) then
|
|
421
442
|
end
|
422
443
|
table.insert(failed, jobId)
|
423
444
|
else
|
424
|
-
local target,
|
425
|
-
getTargetQueueList(metaKey, waitKey, pausedKey)
|
445
|
+
local target, isPausedOrMaxed=
|
446
|
+
getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)
|
426
447
|
-- Move the job back to the wait queue, to immediately be picked up by a waiting worker.
|
427
|
-
addJobInTargetList(target, markerKey, "RPUSH",
|
448
|
+
addJobInTargetList(target, markerKey, "RPUSH", isPausedOrMaxed, jobId)
|
428
449
|
rcall("XADD", eventStreamKey, "*", "event",
|
429
450
|
"waiting", "jobId", jobId, 'prev', 'active')
|
430
451
|
-- Emit the stalled event
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgdS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -69,12 +69,21 @@ end
|
|
69
69
|
Function to check for the meta.paused key to decide if we are paused or not
|
70
70
|
(since an empty list and !EXISTS are not really the same).
|
71
71
|
]]
|
72
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
73
|
-
|
74
|
-
|
75
|
-
else
|
72
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
73
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
74
|
+
if queueAttributes[1] then
|
76
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
|
77
85
|
end
|
86
|
+
return waitKey, false
|
78
87
|
end
|
79
88
|
--[[
|
80
89
|
Function to move job from prioritized state to active.
|
@@ -137,24 +146,25 @@ end
|
|
137
146
|
--[[
|
138
147
|
Add marker if needed when a job is available.
|
139
148
|
]]
|
140
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
141
|
-
if not
|
149
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
150
|
+
if not isPausedOrMaxed then
|
142
151
|
rcall("ZADD", markerKey, 0, "0")
|
143
152
|
end
|
144
153
|
end
|
145
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
154
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
146
155
|
rcall(pushCmd, targetKey, jobId)
|
147
|
-
addBaseMarkerIfNeeded(markerKey,
|
156
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
148
157
|
end
|
149
158
|
--[[
|
150
159
|
Function to add job considering priority.
|
151
160
|
]]
|
152
161
|
-- Includes
|
153
|
-
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
162
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
163
|
+
isPausedOrMaxed)
|
154
164
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
155
165
|
local score = priority * 0x100000000 + prioCounter % 0x100000000
|
156
166
|
rcall("ZADD", prioritizedKey, score, jobId)
|
157
|
-
addBaseMarkerIfNeeded(markerKey,
|
167
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
158
168
|
end
|
159
169
|
-- Try to get as much as 1000 jobs at once
|
160
170
|
local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
|
@@ -180,17 +190,17 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
|
|
180
190
|
end
|
181
191
|
end
|
182
192
|
end
|
183
|
-
local target,
|
193
|
+
local target, isPausedOrMaxed = getTargetQueueList(KEYS[9], activeKey, waitKey, KEYS[8])
|
184
194
|
-- Check if there are delayed jobs that we can move to wait.
|
185
195
|
local markerKey = KEYS[11]
|
186
196
|
promoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], eventStreamKey, ARGV[1],
|
187
|
-
ARGV[2], KEYS[10],
|
197
|
+
ARGV[2], KEYS[10], isPausedOrMaxed)
|
188
198
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
189
199
|
local expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)
|
190
200
|
-- Check if we are rate limited first.
|
191
201
|
if expireTime > 0 then return {0, 0, expireTime, 0} end
|
192
|
-
-- paused queue
|
193
|
-
if
|
202
|
+
-- paused or maxed queue
|
203
|
+
if isPausedOrMaxed then return {0, 0, 0, 0} end
|
194
204
|
-- no job ID, try non-blocking move from wait to active
|
195
205
|
local jobId = rcall("RPOPLPUSH", waitKey, activeKey)
|
196
206
|
-- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Nf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -86,13 +86,6 @@ local function getOrSetMaxEvents(metaKey)
|
|
86
86
|
end
|
87
87
|
return maxEvents
|
88
88
|
end
|
89
|
-
--[[
|
90
|
-
Function to check for the meta.paused key to decide if we are paused or not
|
91
|
-
(since an empty list and !EXISTS are not really the same).
|
92
|
-
]]
|
93
|
-
local function isQueuePaused(queueMetaKey)
|
94
|
-
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
95
|
-
end
|
96
89
|
local function removeLock(jobKey, stalledKey, token, jobId)
|
97
90
|
if token ~= "0" then
|
98
91
|
local lockKey = jobKey .. ':lock'
|
@@ -135,11 +128,8 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
135
128
|
rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
136
129
|
"jobId", jobId, "delay", delayedTimestamp)
|
137
130
|
-- Check if we need to push a marker job to wake up sleeping workers.
|
138
|
-
local
|
139
|
-
|
140
|
-
local markerKey = KEYS[1]
|
141
|
-
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
142
|
-
end
|
131
|
+
local markerKey = KEYS[1]
|
132
|
+
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
143
133
|
return 0
|
144
134
|
else
|
145
135
|
return -1
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqIf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|