bullmq 5.8.7 → 5.10.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/repeat.js +44 -30
- package/dist/cjs/classes/repeat.js.map +1 -1
- package/dist/cjs/classes/scripts.js +44 -5
- 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/addRepeatableJob-2.lua +69 -0
- 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/cjs/commands/obliterate-2.lua +23 -8
- 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/cjs/commands/removeRepeatable-2.lua +27 -6
- 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/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/interfaces/repeatable-options.js +3 -0
- package/dist/cjs/interfaces/repeatable-options.js.map +1 -0
- 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/addRepeatableJob-2.js +66 -0
- package/dist/cjs/scripts/addRepeatableJob-2.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 +9 -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 +41 -18
- 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/removeRepeatable-2.js +29 -6
- package/dist/cjs/scripts/removeRepeatable-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/repeat.d.ts +2 -0
- package/dist/esm/classes/repeat.js +44 -30
- package/dist/esm/classes/repeat.js.map +1 -1
- package/dist/esm/classes/scripts.d.ts +6 -2
- package/dist/esm/classes/scripts.js +44 -5
- 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/addRepeatableJob-2.lua +69 -0
- 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/esm/commands/obliterate-2.lua +23 -8
- 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/esm/commands/removeRepeatable-2.lua +27 -6
- 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/interfaces/index.d.ts +1 -0
- package/dist/esm/interfaces/index.js +1 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/repeatable-job.d.ts +3 -2
- package/dist/esm/interfaces/repeatable-options.d.ts +7 -0
- package/dist/esm/interfaces/repeatable-options.js +2 -0
- package/dist/esm/interfaces/repeatable-options.js.map +1 -0
- 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/addRepeatableJob-2.d.ts +5 -0
- package/dist/esm/scripts/addRepeatableJob-2.js +63 -0
- package/dist/esm/scripts/addRepeatableJob-2.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 +9 -7
- package/dist/esm/scripts/index.js +9 -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 +41 -18
- 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/removeRepeatable-2.js +29 -6
- package/dist/esm/scripts/removeRepeatable-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
@@ -5,8 +5,9 @@ const content = `--[[
|
|
5
5
|
KEYS[2] 'paused'
|
6
6
|
KEYS[3] 'meta'
|
7
7
|
KEYS[4] 'prioritized'
|
8
|
-
KEYS[5] '
|
9
|
-
KEYS[6] '
|
8
|
+
KEYS[5] 'active'
|
9
|
+
KEYS[6] 'pc' priority counter
|
10
|
+
KEYS[7] 'marker'
|
10
11
|
ARGV[1] priority value
|
11
12
|
ARGV[2] job key
|
12
13
|
ARGV[3] job id
|
@@ -27,35 +28,45 @@ local rcall = redis.call
|
|
27
28
|
--[[
|
28
29
|
Add marker if needed when a job is available.
|
29
30
|
]]
|
30
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
31
|
-
if not
|
31
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
32
|
+
if not isPausedOrMaxed then
|
32
33
|
rcall("ZADD", markerKey, 0, "0")
|
33
34
|
end
|
34
35
|
end
|
35
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
36
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
36
37
|
rcall(pushCmd, targetKey, jobId)
|
37
|
-
addBaseMarkerIfNeeded(markerKey,
|
38
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
38
39
|
end
|
39
40
|
--[[
|
40
41
|
Function to add job considering priority.
|
41
42
|
]]
|
42
43
|
-- Includes
|
43
|
-
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
44
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
45
|
+
isPausedOrMaxed)
|
44
46
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
45
47
|
local score = priority * 0x100000000 + prioCounter % 0x100000000
|
46
48
|
rcall("ZADD", prioritizedKey, score, jobId)
|
47
|
-
addBaseMarkerIfNeeded(markerKey,
|
49
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
48
50
|
end
|
49
51
|
--[[
|
50
52
|
Function to check for the meta.paused key to decide if we are paused or not
|
51
53
|
(since an empty list and !EXISTS are not really the same).
|
52
54
|
]]
|
53
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
54
|
-
|
55
|
-
|
56
|
-
else
|
55
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
56
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
57
|
+
if queueAttributes[1] then
|
57
58
|
return pausedKey, true
|
59
|
+
else
|
60
|
+
if queueAttributes[2] then
|
61
|
+
local activeCount = rcall("LLEN", activeKey)
|
62
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
63
|
+
return waitKey, true
|
64
|
+
else
|
65
|
+
return waitKey, false
|
66
|
+
end
|
67
|
+
end
|
58
68
|
end
|
69
|
+
return waitKey, false
|
59
70
|
end
|
60
71
|
--[[
|
61
72
|
Function to push back job considering priority in front of same prioritized jobs.
|
@@ -67,31 +78,32 @@ local function pushBackJobWithPriority(prioritizedKey, priority, jobId)
|
|
67
78
|
rcall("ZADD", prioritizedKey, score, jobId)
|
68
79
|
end
|
69
80
|
local function reAddJobWithNewPriority( prioritizedKey, markerKey, targetKey,
|
70
|
-
priorityCounter, lifo, priority, jobId,
|
81
|
+
priorityCounter, lifo, priority, jobId, isPausedOrMaxed)
|
71
82
|
if priority == 0 then
|
72
83
|
local pushCmd = lifo and 'RPUSH' or 'LPUSH'
|
73
|
-
addJobInTargetList(targetKey, markerKey, pushCmd,
|
84
|
+
addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
74
85
|
else
|
75
86
|
if lifo then
|
76
87
|
pushBackJobWithPriority(prioritizedKey, priority, jobId)
|
77
88
|
else
|
78
89
|
addJobWithPriority(markerKey, prioritizedKey, priority, jobId,
|
79
|
-
priorityCounter,
|
90
|
+
priorityCounter, isPausedOrMaxed)
|
80
91
|
end
|
81
92
|
end
|
82
93
|
end
|
83
94
|
if rcall("EXISTS", jobKey) == 1 then
|
84
95
|
local metaKey = KEYS[3]
|
85
|
-
local target,
|
86
|
-
local markerKey = KEYS[6]
|
96
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[5], KEYS[1], KEYS[2])
|
87
97
|
local prioritizedKey = KEYS[4]
|
98
|
+
local priorityCounterKey = KEYS[6]
|
99
|
+
local markerKey = KEYS[7]
|
88
100
|
-- Re-add with the new priority
|
89
101
|
if rcall("ZREM", KEYS[4], jobId) > 0 then
|
90
102
|
reAddJobWithNewPriority( prioritizedKey, markerKey, target,
|
91
|
-
|
103
|
+
priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)
|
92
104
|
elseif rcall("LREM", target, -1, jobId) > 0 then
|
93
105
|
reAddJobWithNewPriority( prioritizedKey, markerKey, target,
|
94
|
-
|
106
|
+
priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)
|
95
107
|
end
|
96
108
|
rcall("HSET", jobKey, "priority", priority)
|
97
109
|
return 0
|
@@ -102,6 +114,6 @@ end
|
|
102
114
|
export const changePriority = {
|
103
115
|
name: 'changePriority',
|
104
116
|
content,
|
105
|
-
keys:
|
117
|
+
keys: 7,
|
106
118
|
};
|
107
|
-
//# sourceMappingURL=changePriority-
|
119
|
+
//# sourceMappingURL=changePriority-7.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"changePriority-7.js","sourceRoot":"","sources":["../../../src/scripts/changePriority-7.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgHf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -67,14 +67,14 @@ end
|
|
67
67
|
--[[
|
68
68
|
Add marker if needed when a job is available.
|
69
69
|
]]
|
70
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
71
|
-
if not
|
70
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
71
|
+
if not isPausedOrMaxed then
|
72
72
|
rcall("ZADD", markerKey, 0, "0")
|
73
73
|
end
|
74
74
|
end
|
75
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
75
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
76
76
|
rcall(pushCmd, targetKey, jobId)
|
77
|
-
addBaseMarkerIfNeeded(markerKey,
|
77
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
78
78
|
end
|
79
79
|
--[[
|
80
80
|
Functions to destructure job key.
|
@@ -90,17 +90,26 @@ end
|
|
90
90
|
Function to check for the meta.paused key to decide if we are paused or not
|
91
91
|
(since an empty list and !EXISTS are not really the same).
|
92
92
|
]]
|
93
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
94
|
-
|
95
|
-
|
96
|
-
else
|
93
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
94
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
95
|
+
if queueAttributes[1] then
|
97
96
|
return pausedKey, true
|
97
|
+
else
|
98
|
+
if queueAttributes[2] then
|
99
|
+
local activeCount = rcall("LLEN", activeKey)
|
100
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
101
|
+
return waitKey, true
|
102
|
+
else
|
103
|
+
return waitKey, false
|
104
|
+
end
|
105
|
+
end
|
98
106
|
end
|
107
|
+
return waitKey, false
|
99
108
|
end
|
100
109
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
101
|
-
local parentTarget,
|
102
|
-
parentPrefix .. "paused")
|
103
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
110
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
111
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
112
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
104
113
|
if emitEvent then
|
105
114
|
local parentEventStream = parentPrefix .. "events"
|
106
115
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Sf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -42,14 +42,14 @@ end
|
|
42
42
|
--[[
|
43
43
|
Add marker if needed when a job is available.
|
44
44
|
]]
|
45
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
46
|
-
if not
|
45
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
46
|
+
if not isPausedOrMaxed then
|
47
47
|
rcall("ZADD", markerKey, 0, "0")
|
48
48
|
end
|
49
49
|
end
|
50
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
50
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
51
51
|
rcall(pushCmd, targetKey, jobId)
|
52
|
-
addBaseMarkerIfNeeded(markerKey,
|
52
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
53
53
|
end
|
54
54
|
--[[
|
55
55
|
Functions to destructure job key.
|
@@ -65,17 +65,26 @@ end
|
|
65
65
|
Function to check for the meta.paused key to decide if we are paused or not
|
66
66
|
(since an empty list and !EXISTS are not really the same).
|
67
67
|
]]
|
68
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
69
|
-
|
70
|
-
|
71
|
-
else
|
68
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
69
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
70
|
+
if queueAttributes[1] then
|
72
71
|
return pausedKey, true
|
72
|
+
else
|
73
|
+
if queueAttributes[2] then
|
74
|
+
local activeCount = rcall("LLEN", activeKey)
|
75
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
76
|
+
return waitKey, true
|
77
|
+
else
|
78
|
+
return waitKey, false
|
79
|
+
end
|
80
|
+
end
|
73
81
|
end
|
82
|
+
return waitKey, false
|
74
83
|
end
|
75
84
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
76
|
-
local parentTarget,
|
77
|
-
parentPrefix .. "paused")
|
78
|
-
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH",
|
85
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
86
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
87
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
79
88
|
if emitEvent then
|
80
89
|
local parentEventStream = parentPrefix .. "events"
|
81
90
|
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;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -17,18 +17,17 @@ local prioritizedKey = KEYS[4]
|
|
17
17
|
Function to check for the meta.paused key to decide if we are paused or not
|
18
18
|
(since an empty list and !EXISTS are not really the same).
|
19
19
|
]]
|
20
|
-
local function
|
21
|
-
|
22
|
-
return waitKey, false
|
23
|
-
else
|
24
|
-
return pausedKey, true
|
25
|
-
end
|
20
|
+
local function isQueuePaused(queueMetaKey)
|
21
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
26
22
|
end
|
27
23
|
for i = 1, #ARGV do
|
28
24
|
local priority = tonumber(ARGV[i])
|
29
25
|
if priority == 0 then
|
30
|
-
|
31
|
-
|
26
|
+
if isQueuePaused(KEYS[3]) then
|
27
|
+
results[#results+1] = rcall("LLEN", pausedKey)
|
28
|
+
else
|
29
|
+
results[#results+1] = rcall("LLEN", waitKey)
|
30
|
+
end
|
32
31
|
else
|
33
32
|
results[#results+1] = rcall("ZCOUNT", prioritizedKey,
|
34
33
|
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;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,sBAAsB;IAC5B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
export * from './addDelayedJob-6';
|
2
2
|
export * from './addLog-2';
|
3
3
|
export * from './addParentJob-4';
|
4
|
-
export * from './addPrioritizedJob-
|
5
|
-
export * from './
|
4
|
+
export * from './addPrioritizedJob-8';
|
5
|
+
export * from './addRepeatableJob-2';
|
6
|
+
export * from './addStandardJob-8';
|
6
7
|
export * from './changeDelay-4';
|
7
|
-
export * from './changePriority-
|
8
|
+
export * from './changePriority-7';
|
8
9
|
export * from './cleanJobsInSet-2';
|
9
10
|
export * from './drain-4';
|
10
11
|
export * from './extendLock-2';
|
@@ -16,8 +17,9 @@ export * from './getState-8';
|
|
16
17
|
export * from './getStateV2-8';
|
17
18
|
export * from './isFinished-3';
|
18
19
|
export * from './isJobInList-1';
|
20
|
+
export * from './isMaxed-2';
|
19
21
|
export * from './moveJobFromActiveToWait-10';
|
20
|
-
export * from './moveJobsToWait-
|
22
|
+
export * from './moveJobsToWait-8';
|
21
23
|
export * from './moveStalledJobsToWait-9';
|
22
24
|
export * from './moveToActive-11';
|
23
25
|
export * from './moveToDelayed-8';
|
@@ -26,12 +28,12 @@ export * from './moveToWaitingChildren-5';
|
|
26
28
|
export * from './obliterate-2';
|
27
29
|
export * from './paginate-1';
|
28
30
|
export * from './pause-7';
|
29
|
-
export * from './promote-
|
31
|
+
export * from './promote-9';
|
30
32
|
export * from './releaseLock-1';
|
31
33
|
export * from './removeChildDependency-1';
|
32
|
-
export * from './removeJob-
|
34
|
+
export * from './removeJob-2';
|
33
35
|
export * from './removeRepeatable-2';
|
34
|
-
export * from './reprocessJob-
|
36
|
+
export * from './reprocessJob-8';
|
35
37
|
export * from './retryJob-11';
|
36
38
|
export * from './saveStacktrace-1';
|
37
39
|
export * from './updateData-1';
|
@@ -1,10 +1,11 @@
|
|
1
1
|
export * from './addDelayedJob-6';
|
2
2
|
export * from './addLog-2';
|
3
3
|
export * from './addParentJob-4';
|
4
|
-
export * from './addPrioritizedJob-
|
5
|
-
export * from './
|
4
|
+
export * from './addPrioritizedJob-8';
|
5
|
+
export * from './addRepeatableJob-2';
|
6
|
+
export * from './addStandardJob-8';
|
6
7
|
export * from './changeDelay-4';
|
7
|
-
export * from './changePriority-
|
8
|
+
export * from './changePriority-7';
|
8
9
|
export * from './cleanJobsInSet-2';
|
9
10
|
export * from './drain-4';
|
10
11
|
export * from './extendLock-2';
|
@@ -16,8 +17,9 @@ export * from './getState-8';
|
|
16
17
|
export * from './getStateV2-8';
|
17
18
|
export * from './isFinished-3';
|
18
19
|
export * from './isJobInList-1';
|
20
|
+
export * from './isMaxed-2';
|
19
21
|
export * from './moveJobFromActiveToWait-10';
|
20
|
-
export * from './moveJobsToWait-
|
22
|
+
export * from './moveJobsToWait-8';
|
21
23
|
export * from './moveStalledJobsToWait-9';
|
22
24
|
export * from './moveToActive-11';
|
23
25
|
export * from './moveToDelayed-8';
|
@@ -26,12 +28,12 @@ export * from './moveToWaitingChildren-5';
|
|
26
28
|
export * from './obliterate-2';
|
27
29
|
export * from './paginate-1';
|
28
30
|
export * from './pause-7';
|
29
|
-
export * from './promote-
|
31
|
+
export * from './promote-9';
|
30
32
|
export * from './releaseLock-1';
|
31
33
|
export * from './removeChildDependency-1';
|
32
|
-
export * from './removeJob-
|
34
|
+
export * from './removeJob-2';
|
33
35
|
export * from './removeRepeatable-2';
|
34
|
-
export * from './reprocessJob-
|
36
|
+
export * from './reprocessJob-8';
|
35
37
|
export * from './retryJob-11';
|
36
38
|
export * from './saveStacktrace-1';
|
37
39
|
export * from './updateData-1';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
const content = `--[[
|
2
|
+
Checks if queue is maxed.
|
3
|
+
Input:
|
4
|
+
KEYS[1] meta key
|
5
|
+
KEYS[2] active key
|
6
|
+
Output:
|
7
|
+
1 if element found in the list.
|
8
|
+
]]
|
9
|
+
local rcall = redis.call
|
10
|
+
-- Includes
|
11
|
+
--[[
|
12
|
+
Function to check if queue is maxed or not.
|
13
|
+
]]
|
14
|
+
local function isQueueMaxed(queueMetaKey, activeKey)
|
15
|
+
local maxConcurrency = rcall("HGET", queueMetaKey, "concurrency")
|
16
|
+
if maxConcurrency then
|
17
|
+
local activeCount = rcall("LLEN", activeKey)
|
18
|
+
if activeCount >= tonumber(maxConcurrency) then
|
19
|
+
return true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
return isQueueMaxed(KEYS[1], KEYS[2])
|
25
|
+
`;
|
26
|
+
export const isMaxed = {
|
27
|
+
name: 'isMaxed',
|
28
|
+
content,
|
29
|
+
keys: 2,
|
30
|
+
};
|
31
|
+
//# 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;AACF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -24,14 +24,14 @@ local rcall = redis.call
|
|
24
24
|
--[[
|
25
25
|
Add marker if needed when a job is available.
|
26
26
|
]]
|
27
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
28
|
-
if not
|
27
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
28
|
+
if not isPausedOrMaxed then
|
29
29
|
rcall("ZADD", markerKey, 0, "0")
|
30
30
|
end
|
31
31
|
end
|
32
|
-
local function addJobInTargetList(targetKey, markerKey, pushCmd,
|
32
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
33
33
|
rcall(pushCmd, targetKey, jobId)
|
34
|
-
addBaseMarkerIfNeeded(markerKey,
|
34
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
35
35
|
end
|
36
36
|
--[[
|
37
37
|
Function to push back job considering priority in front of same prioritized jobs.
|
@@ -57,12 +57,21 @@ end
|
|
57
57
|
Function to check for the meta.paused key to decide if we are paused or not
|
58
58
|
(since an empty list and !EXISTS are not really the same).
|
59
59
|
]]
|
60
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
61
|
-
|
62
|
-
|
63
|
-
else
|
60
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
61
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
62
|
+
if queueAttributes[1] then
|
64
63
|
return pausedKey, true
|
64
|
+
else
|
65
|
+
if queueAttributes[2] then
|
66
|
+
local activeCount = rcall("LLEN", activeKey)
|
67
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
68
|
+
return waitKey, true
|
69
|
+
else
|
70
|
+
return waitKey, false
|
71
|
+
end
|
72
|
+
end
|
65
73
|
end
|
74
|
+
return waitKey, false
|
66
75
|
end
|
67
76
|
local jobId = ARGV[1]
|
68
77
|
local token = ARGV[2]
|
@@ -73,13 +82,13 @@ if lockToken == token then
|
|
73
82
|
local metaKey = KEYS[6]
|
74
83
|
local removed = rcall("LREM", KEYS[1], 1, jobId)
|
75
84
|
if removed > 0 then
|
76
|
-
local target,
|
85
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[5])
|
77
86
|
rcall("SREM", KEYS[3], jobId)
|
78
87
|
local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0
|
79
88
|
if priority > 0 then
|
80
89
|
pushBackJobWithPriority(KEYS[8], priority, jobId)
|
81
90
|
else
|
82
|
-
addJobInTargetList(target, KEYS[9], "RPUSH",
|
91
|
+
addJobInTargetList(target, KEYS[9], "RPUSH", isPausedOrMaxed, jobId)
|
83
92
|
end
|
84
93
|
rcall("DEL", lockKey)
|
85
94
|
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;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -8,7 +8,8 @@ const content = `--[[
|
|
8
8
|
KEYS[4] 'wait'
|
9
9
|
KEYS[5] 'paused'
|
10
10
|
KEYS[6] 'meta'
|
11
|
-
KEYS[7] '
|
11
|
+
KEYS[7] 'active'
|
12
|
+
KEYS[8] 'marker'
|
12
13
|
ARGV[1] count
|
13
14
|
ARGV[2] timestamp
|
14
15
|
ARGV[3] prev state
|
@@ -23,8 +24,8 @@ local rcall = redis.call;
|
|
23
24
|
--[[
|
24
25
|
Add marker if needed when a job is available.
|
25
26
|
]]
|
26
|
-
local function addBaseMarkerIfNeeded(markerKey,
|
27
|
-
if not
|
27
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
28
|
+
if not isPausedOrMaxed then
|
28
29
|
rcall("ZADD", markerKey, 0, "0")
|
29
30
|
end
|
30
31
|
end
|
@@ -59,15 +60,24 @@ end
|
|
59
60
|
Function to check for the meta.paused key to decide if we are paused or not
|
60
61
|
(since an empty list and !EXISTS are not really the same).
|
61
62
|
]]
|
62
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
63
|
-
|
64
|
-
|
65
|
-
else
|
63
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
64
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
65
|
+
if queueAttributes[1] then
|
66
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
|
67
76
|
end
|
77
|
+
return waitKey, false
|
68
78
|
end
|
69
79
|
local metaKey = KEYS[6]
|
70
|
-
local target,
|
80
|
+
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])
|
71
81
|
local jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)
|
72
82
|
if (#jobs > 0) then
|
73
83
|
if ARGV[3] == "failed" then
|
@@ -91,7 +101,7 @@ if (#jobs > 0) then
|
|
91
101
|
rcall("ZREM", KEYS[3], unpack(jobs, from, to))
|
92
102
|
rcall("LPUSH", target, unpack(jobs, from, to))
|
93
103
|
end
|
94
|
-
addBaseMarkerIfNeeded(KEYS[
|
104
|
+
addBaseMarkerIfNeeded(KEYS[8], isPausedOrMaxed)
|
95
105
|
end
|
96
106
|
maxCount = maxCount - #jobs
|
97
107
|
if (maxCount <= 0) then return 1 end
|
@@ -100,6 +110,6 @@ return 0
|
|
100
110
|
export const moveJobsToWait = {
|
101
111
|
name: 'moveJobsToWait',
|
102
112
|
content,
|
103
|
-
keys:
|
113
|
+
keys: 8,
|
104
114
|
};
|
105
|
-
//# sourceMappingURL=moveJobsToWait-
|
115
|
+
//# 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;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|