bullmq 5.59.0 → 5.60.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 +9 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.js +4 -1
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/changePriority-7.lua +1 -1
- package/dist/cjs/commands/{getRateLimitTtl-1.lua → getRateLimitTtl-2.lua} +6 -0
- package/dist/cjs/commands/includes/getTargetQueueList.lua +5 -5
- package/dist/cjs/commands/includes/prepareJobForProcessing.lua +2 -4
- package/dist/cjs/commands/moveStalledJobsToWait-8.lua +0 -1
- package/dist/cjs/commands/moveToActive-11.lua +7 -4
- package/dist/cjs/commands/moveToFinished-14.lua +10 -7
- package/dist/cjs/scripts/addDelayedJob-6.js +5 -5
- package/dist/cjs/scripts/addJobScheduler-11.js +5 -5
- package/dist/cjs/scripts/addParentJob-5.js +5 -5
- package/dist/cjs/scripts/addPrioritizedJob-9.js +5 -5
- package/dist/cjs/scripts/addRepeatableJob-2.js +5 -5
- package/dist/cjs/scripts/addStandardJob-9.js +5 -5
- package/dist/cjs/scripts/changePriority-7.js +5 -5
- package/dist/cjs/scripts/cleanJobsInSet-3.js +5 -5
- package/dist/cjs/scripts/drain-5.js +5 -5
- package/dist/cjs/scripts/{getRateLimitTtl-1.js → getRateLimitTtl-2.js} +7 -2
- package/dist/cjs/scripts/getRateLimitTtl-2.js.map +1 -0
- package/dist/cjs/scripts/index.js +1 -1
- package/dist/cjs/scripts/moveJobFromActiveToWait-9.js +5 -5
- package/dist/cjs/scripts/moveJobsToWait-8.js +5 -5
- package/dist/cjs/scripts/moveStalledJobsToWait-8.js +9 -9
- package/dist/cjs/scripts/moveToActive-11.js +13 -12
- package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +16 -15
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +5 -5
- package/dist/cjs/scripts/promote-9.js +5 -5
- package/dist/cjs/scripts/removeChildDependency-1.js +5 -5
- package/dist/cjs/scripts/removeJob-2.js +5 -5
- package/dist/cjs/scripts/removeUnprocessedChildren-2.js +5 -5
- package/dist/cjs/scripts/reprocessJob-8.js +5 -5
- package/dist/cjs/scripts/retryJob-11.js +5 -5
- package/dist/cjs/scripts/updateJobScheduler-12.js +5 -5
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/queue.d.ts +6 -0
- package/dist/esm/classes/queue.js +9 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.js +4 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/changePriority-7.lua +1 -1
- package/dist/esm/commands/{getRateLimitTtl-1.lua → getRateLimitTtl-2.lua} +6 -0
- package/dist/esm/commands/includes/getTargetQueueList.lua +5 -5
- package/dist/esm/commands/includes/prepareJobForProcessing.lua +2 -4
- package/dist/esm/commands/moveStalledJobsToWait-8.lua +0 -1
- package/dist/esm/commands/moveToActive-11.lua +7 -4
- package/dist/esm/commands/moveToFinished-14.lua +10 -7
- package/dist/esm/scripts/addDelayedJob-6.js +5 -5
- package/dist/esm/scripts/addJobScheduler-11.js +5 -5
- package/dist/esm/scripts/addParentJob-5.js +5 -5
- package/dist/esm/scripts/addPrioritizedJob-9.js +5 -5
- package/dist/esm/scripts/addRepeatableJob-2.js +5 -5
- package/dist/esm/scripts/addStandardJob-9.js +5 -5
- package/dist/esm/scripts/changePriority-7.js +5 -5
- package/dist/esm/scripts/cleanJobsInSet-3.js +5 -5
- package/dist/esm/scripts/drain-5.js +5 -5
- package/dist/esm/scripts/{getRateLimitTtl-1.js → getRateLimitTtl-2.js} +7 -2
- package/dist/esm/scripts/getRateLimitTtl-2.js.map +1 -0
- package/dist/esm/scripts/index.d.ts +1 -1
- package/dist/esm/scripts/index.js +1 -1
- package/dist/esm/scripts/moveJobFromActiveToWait-9.js +5 -5
- package/dist/esm/scripts/moveJobsToWait-8.js +5 -5
- package/dist/esm/scripts/moveStalledJobsToWait-8.js +9 -9
- package/dist/esm/scripts/moveToActive-11.js +13 -12
- package/dist/esm/scripts/moveToActive-11.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +16 -15
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +5 -5
- package/dist/esm/scripts/promote-9.js +5 -5
- package/dist/esm/scripts/removeChildDependency-1.js +5 -5
- package/dist/esm/scripts/removeJob-2.js +5 -5
- package/dist/esm/scripts/removeUnprocessedChildren-2.js +5 -5
- package/dist/esm/scripts/reprocessJob-8.js +5 -5
- package/dist/esm/scripts/retryJob-11.js +5 -5
- package/dist/esm/scripts/updateJobScheduler-12.js +5 -5
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/scripts/getRateLimitTtl-1.js.map +0 -1
- package/dist/esm/scripts/getRateLimitTtl-1.js.map +0 -1
- /package/dist/esm/scripts/{getRateLimitTtl-1.d.ts → getRateLimitTtl-2.d.ts} +0 -0
|
@@ -188,20 +188,20 @@ end
|
|
|
188
188
|
(since an empty list and !EXISTS are not really the same).
|
|
189
189
|
]]
|
|
190
190
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
191
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
191
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
192
192
|
if queueAttributes[1] then
|
|
193
|
-
return pausedKey, true
|
|
193
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
194
194
|
else
|
|
195
195
|
if queueAttributes[2] then
|
|
196
196
|
local activeCount = rcall("LLEN", activeKey)
|
|
197
197
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
198
|
-
return waitKey, true
|
|
198
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
199
199
|
else
|
|
200
|
-
return waitKey, false
|
|
200
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
end
|
|
204
|
-
return waitKey, false
|
|
204
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
205
205
|
end
|
|
206
206
|
--[[
|
|
207
207
|
Function to handle the case when job is duplicated.
|
|
@@ -62,20 +62,20 @@ end
|
|
|
62
62
|
(since an empty list and !EXISTS are not really the same).
|
|
63
63
|
]]
|
|
64
64
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
65
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
65
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
66
66
|
if queueAttributes[1] then
|
|
67
|
-
return pausedKey, true
|
|
67
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
68
68
|
else
|
|
69
69
|
if queueAttributes[2] then
|
|
70
70
|
local activeCount = rcall("LLEN", activeKey)
|
|
71
71
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
72
|
-
return waitKey, true
|
|
72
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
73
73
|
else
|
|
74
|
-
return waitKey, false
|
|
74
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
-
return waitKey, false
|
|
78
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
79
79
|
end
|
|
80
80
|
--[[
|
|
81
81
|
Function to push back job considering priority in front of same prioritized jobs.
|
|
@@ -126,20 +126,20 @@ end
|
|
|
126
126
|
(since an empty list and !EXISTS are not really the same).
|
|
127
127
|
]]
|
|
128
128
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
129
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
129
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
130
130
|
if queueAttributes[1] then
|
|
131
|
-
return pausedKey, true
|
|
131
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
132
132
|
else
|
|
133
133
|
if queueAttributes[2] then
|
|
134
134
|
local activeCount = rcall("LLEN", activeKey)
|
|
135
135
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
136
|
-
return waitKey, true
|
|
136
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
137
137
|
else
|
|
138
|
-
return waitKey, false
|
|
138
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
|
-
return waitKey, false
|
|
142
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
143
143
|
end
|
|
144
144
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
145
145
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -98,20 +98,20 @@ end
|
|
|
98
98
|
(since an empty list and !EXISTS are not really the same).
|
|
99
99
|
]]
|
|
100
100
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
101
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
101
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
102
102
|
if queueAttributes[1] then
|
|
103
|
-
return pausedKey, true
|
|
103
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
104
104
|
else
|
|
105
105
|
if queueAttributes[2] then
|
|
106
106
|
local activeCount = rcall("LLEN", activeKey)
|
|
107
107
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
108
|
-
return waitKey, true
|
|
108
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
109
109
|
else
|
|
110
|
-
return waitKey, false
|
|
110
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
|
-
return waitKey, false
|
|
114
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
115
115
|
end
|
|
116
116
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
117
117
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -5,6 +5,7 @@ const content = `--[[
|
|
|
5
5
|
Get rate limit ttl
|
|
6
6
|
Input:
|
|
7
7
|
KEYS[1] 'limiter'
|
|
8
|
+
KEYS[2] 'meta'
|
|
8
9
|
ARGV[1] maxJobs
|
|
9
10
|
]]
|
|
10
11
|
local rcall = redis.call
|
|
@@ -28,12 +29,16 @@ local rateLimiterKey = KEYS[1]
|
|
|
28
29
|
if ARGV[1] ~= "0" then
|
|
29
30
|
return getRateLimitTTL(tonumber(ARGV[1]), rateLimiterKey)
|
|
30
31
|
else
|
|
32
|
+
local rateLimitMax = rcall("HGET", KEYS[2], "max")
|
|
33
|
+
if rateLimitMax then
|
|
34
|
+
return getRateLimitTTL(tonumber(rateLimitMax), rateLimiterKey)
|
|
35
|
+
end
|
|
31
36
|
return rcall("PTTL", rateLimiterKey)
|
|
32
37
|
end
|
|
33
38
|
`;
|
|
34
39
|
exports.getRateLimitTtl = {
|
|
35
40
|
name: 'getRateLimitTtl',
|
|
36
41
|
content,
|
|
37
|
-
keys:
|
|
42
|
+
keys: 2,
|
|
38
43
|
};
|
|
39
|
-
//# sourceMappingURL=getRateLimitTtl-
|
|
44
|
+
//# sourceMappingURL=getRateLimitTtl-2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRateLimitTtl-2.js","sourceRoot":"","sources":["../../../src/scripts/getRateLimitTtl-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCf,CAAC;AACW,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -20,7 +20,7 @@ tslib_1.__exportStar(require("./getDependencyCounts-4"), exports);
|
|
|
20
20
|
tslib_1.__exportStar(require("./getJobScheduler-1"), exports);
|
|
21
21
|
tslib_1.__exportStar(require("./getMetrics-2"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./getRanges-1"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./getRateLimitTtl-
|
|
23
|
+
tslib_1.__exportStar(require("./getRateLimitTtl-2"), exports);
|
|
24
24
|
tslib_1.__exportStar(require("./getState-8"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./getStateV2-8"), exports);
|
|
26
26
|
tslib_1.__exportStar(require("./isFinished-3"), exports);
|
|
@@ -60,20 +60,20 @@ end
|
|
|
60
60
|
(since an empty list and !EXISTS are not really the same).
|
|
61
61
|
]]
|
|
62
62
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
63
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
63
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
64
64
|
if queueAttributes[1] then
|
|
65
|
-
return pausedKey, true
|
|
65
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
66
66
|
else
|
|
67
67
|
if queueAttributes[2] then
|
|
68
68
|
local activeCount = rcall("LLEN", activeKey)
|
|
69
69
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
70
|
-
return waitKey, true
|
|
70
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
71
71
|
else
|
|
72
|
-
return waitKey, false
|
|
72
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
|
-
return waitKey, false
|
|
76
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
77
77
|
end
|
|
78
78
|
local function removeLock(jobKey, stalledKey, token, jobId)
|
|
79
79
|
if token ~= "0" then
|
|
@@ -64,20 +64,20 @@ end
|
|
|
64
64
|
(since an empty list and !EXISTS are not really the same).
|
|
65
65
|
]]
|
|
66
66
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
67
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
67
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
68
68
|
if queueAttributes[1] then
|
|
69
|
-
return pausedKey, true
|
|
69
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
70
70
|
else
|
|
71
71
|
if queueAttributes[2] then
|
|
72
72
|
local activeCount = rcall("LLEN", activeKey)
|
|
73
73
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
74
|
-
return waitKey, true
|
|
74
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
75
75
|
else
|
|
76
|
-
return waitKey, false
|
|
76
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
|
-
return waitKey, false
|
|
80
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
81
81
|
end
|
|
82
82
|
local metaKey = KEYS[6]
|
|
83
83
|
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])
|
|
@@ -53,30 +53,30 @@ local function batches(n, batchSize)
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
|
+
--[[
|
|
57
|
+
Function to move job to wait to be picked up by a waiting worker.
|
|
58
|
+
]]
|
|
59
|
+
-- Includes
|
|
56
60
|
--[[
|
|
57
61
|
Function to check for the meta.paused key to decide if we are paused or not
|
|
58
62
|
(since an empty list and !EXISTS are not really the same).
|
|
59
63
|
]]
|
|
60
64
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
61
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
65
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
62
66
|
if queueAttributes[1] then
|
|
63
|
-
return pausedKey, true
|
|
67
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
64
68
|
else
|
|
65
69
|
if queueAttributes[2] then
|
|
66
70
|
local activeCount = rcall("LLEN", activeKey)
|
|
67
71
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
68
|
-
return waitKey, true
|
|
72
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
69
73
|
else
|
|
70
|
-
return waitKey, false
|
|
74
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
71
75
|
end
|
|
72
76
|
end
|
|
73
77
|
end
|
|
74
|
-
return waitKey, false
|
|
78
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
75
79
|
end
|
|
76
|
-
--[[
|
|
77
|
-
Function to move job to wait to be picked up by a waiting worker.
|
|
78
|
-
]]
|
|
79
|
-
-- Includes
|
|
80
80
|
local function moveJobToWait(metaKey, activeKey, waitKey, pausedKey, markerKey, eventStreamKey,
|
|
81
81
|
jobId, pushCmd)
|
|
82
82
|
local target, isPausedOrMaxed = getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)
|
|
@@ -71,20 +71,20 @@ end
|
|
|
71
71
|
(since an empty list and !EXISTS are not really the same).
|
|
72
72
|
]]
|
|
73
73
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
74
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
74
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
75
75
|
if queueAttributes[1] then
|
|
76
|
-
return pausedKey, true
|
|
76
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
77
77
|
else
|
|
78
78
|
if queueAttributes[2] then
|
|
79
79
|
local activeCount = rcall("LLEN", activeKey)
|
|
80
80
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
81
|
-
return waitKey, true
|
|
81
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
82
82
|
else
|
|
83
|
-
return waitKey, false
|
|
83
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
|
-
return waitKey, false
|
|
87
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
88
88
|
end
|
|
89
89
|
--[[
|
|
90
90
|
Function to move job from prioritized state to active.
|
|
@@ -115,20 +115,19 @@ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
local function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,
|
|
118
|
-
jobId, processedOn, maxJobs, markerKey, opts)
|
|
118
|
+
jobId, processedOn, maxJobs, limiterDuration, markerKey, opts)
|
|
119
119
|
local jobKey = keyPrefix .. jobId
|
|
120
120
|
-- Check if we need to perform rate limiting.
|
|
121
121
|
if maxJobs then
|
|
122
122
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
|
123
123
|
if jobCounter == 1 then
|
|
124
|
-
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
|
125
124
|
local integerDuration = math.floor(math.abs(limiterDuration))
|
|
126
125
|
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
|
127
126
|
end
|
|
128
127
|
end
|
|
129
|
-
local lockKey = jobKey .. ':lock'
|
|
130
128
|
-- get a lock
|
|
131
129
|
if opts['token'] ~= "0" then
|
|
130
|
+
local lockKey = jobKey .. ':lock'
|
|
132
131
|
rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])
|
|
133
132
|
end
|
|
134
133
|
local optionalValues = {}
|
|
@@ -202,17 +201,19 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
|
|
|
202
201
|
addBaseMarkerIfNeeded(markerKey, isPaused)
|
|
203
202
|
end
|
|
204
203
|
end
|
|
205
|
-
local target, isPausedOrMaxed = getTargetQueueList(KEYS[9],
|
|
204
|
+
local target, isPausedOrMaxed, rateLimitMax, rateLimitDuration = getTargetQueueList(KEYS[9],
|
|
205
|
+
activeKey, waitKey, KEYS[8])
|
|
206
206
|
-- Check if there are delayed jobs that we can move to wait.
|
|
207
207
|
local markerKey = KEYS[11]
|
|
208
208
|
promoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], eventStreamKey, ARGV[1],
|
|
209
209
|
ARGV[2], KEYS[10], isPausedOrMaxed)
|
|
210
|
-
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
|
210
|
+
local maxJobs = tonumber(rateLimitMax or (opts['limiter'] and opts['limiter']['max']))
|
|
211
211
|
local expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)
|
|
212
212
|
-- Check if we are rate limited first.
|
|
213
213
|
if expireTime > 0 then return {0, 0, expireTime, 0} end
|
|
214
214
|
-- paused or maxed queue
|
|
215
215
|
if isPausedOrMaxed then return {0, 0, 0, 0} end
|
|
216
|
+
local limiterDuration = (opts['limiter'] and opts['limiter']['duration']) or rateLimitDuration
|
|
216
217
|
-- no job ID, try non-blocking move from wait to active
|
|
217
218
|
local jobId = rcall("RPOPLPUSH", waitKey, activeKey)
|
|
218
219
|
-- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.
|
|
@@ -222,12 +223,12 @@ if jobId and string.sub(jobId, 1, 2) == "0:" then
|
|
|
222
223
|
end
|
|
223
224
|
if jobId then
|
|
224
225
|
return prepareJobForProcessing(ARGV[1], rateLimiterKey, eventStreamKey, jobId, ARGV[2],
|
|
225
|
-
maxJobs, markerKey, opts)
|
|
226
|
+
maxJobs, limiterDuration, markerKey, opts)
|
|
226
227
|
else
|
|
227
228
|
jobId = moveJobFromPrioritizedToActive(KEYS[3], activeKey, KEYS[10])
|
|
228
229
|
if jobId then
|
|
229
230
|
return prepareJobForProcessing(ARGV[1], rateLimiterKey, eventStreamKey, jobId, ARGV[2],
|
|
230
|
-
maxJobs, markerKey, opts)
|
|
231
|
+
maxJobs, limiterDuration, markerKey, opts)
|
|
231
232
|
end
|
|
232
233
|
end
|
|
233
234
|
-- Return the timestamp for the next delayed job if any.
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Of,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -140,20 +140,20 @@ end
|
|
|
140
140
|
(since an empty list and !EXISTS are not really the same).
|
|
141
141
|
]]
|
|
142
142
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
143
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
143
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
144
144
|
if queueAttributes[1] then
|
|
145
|
-
return pausedKey, true
|
|
145
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
146
146
|
else
|
|
147
147
|
if queueAttributes[2] then
|
|
148
148
|
local activeCount = rcall("LLEN", activeKey)
|
|
149
149
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
150
|
-
return waitKey, true
|
|
150
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
151
151
|
else
|
|
152
|
-
return waitKey, false
|
|
152
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
153
153
|
end
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
|
-
return waitKey, false
|
|
156
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
157
157
|
end
|
|
158
158
|
--[[
|
|
159
159
|
Function to move job from prioritized state to active.
|
|
@@ -541,20 +541,19 @@ end
|
|
|
541
541
|
]]
|
|
542
542
|
-- Includes
|
|
543
543
|
local function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,
|
|
544
|
-
jobId, processedOn, maxJobs, markerKey, opts)
|
|
544
|
+
jobId, processedOn, maxJobs, limiterDuration, markerKey, opts)
|
|
545
545
|
local jobKey = keyPrefix .. jobId
|
|
546
546
|
-- Check if we need to perform rate limiting.
|
|
547
547
|
if maxJobs then
|
|
548
548
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
|
549
549
|
if jobCounter == 1 then
|
|
550
|
-
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
|
551
550
|
local integerDuration = math.floor(math.abs(limiterDuration))
|
|
552
551
|
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
|
553
552
|
end
|
|
554
553
|
end
|
|
555
|
-
local lockKey = jobKey .. ':lock'
|
|
556
554
|
-- get a lock
|
|
557
555
|
if opts['token'] ~= "0" then
|
|
556
|
+
local lockKey = jobKey .. ':lock'
|
|
558
557
|
rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])
|
|
559
558
|
end
|
|
560
559
|
local optionalValues = {}
|
|
@@ -792,12 +791,13 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
792
791
|
-- Try to get next job to avoid an extra roundtrip if the queue is not closing,
|
|
793
792
|
-- and not rate limited.
|
|
794
793
|
if (ARGV[6] == "1") then
|
|
795
|
-
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2],
|
|
794
|
+
local target, isPausedOrMaxed, rateLimitMax, rateLimitDuration = getTargetQueueList(metaKey, KEYS[2],
|
|
795
|
+
KEYS[1], KEYS[8])
|
|
796
796
|
local markerKey = KEYS[14]
|
|
797
797
|
-- Check if there are delayed jobs that can be promoted
|
|
798
798
|
promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[3], eventStreamKey, prefix, timestamp, KEYS[10],
|
|
799
799
|
isPausedOrMaxed)
|
|
800
|
-
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
|
800
|
+
local maxJobs = tonumber(rateLimitMax or (opts['limiter'] and opts['limiter']['max']))
|
|
801
801
|
-- Check if we are rate limited first.
|
|
802
802
|
local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
|
|
803
803
|
if expireTime > 0 then
|
|
@@ -807,6 +807,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
807
807
|
if isPausedOrMaxed then
|
|
808
808
|
return {0, 0, 0, 0}
|
|
809
809
|
end
|
|
810
|
+
local limiterDuration = (opts['limiter'] and opts['limiter']['duration']) or rateLimitDuration
|
|
810
811
|
jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
|
|
811
812
|
if jobId then
|
|
812
813
|
-- Markers in waitlist DEPRECATED in v5: Remove in v6.
|
|
@@ -817,17 +818,17 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
817
818
|
if jobId == "0:0" then
|
|
818
819
|
jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])
|
|
819
820
|
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
820
|
-
markerKey, opts)
|
|
821
|
+
limiterDuration, markerKey, opts)
|
|
821
822
|
end
|
|
822
823
|
else
|
|
823
|
-
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
824
|
-
opts)
|
|
824
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
825
|
+
limiterDuration, markerKey, opts)
|
|
825
826
|
end
|
|
826
827
|
else
|
|
827
828
|
jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])
|
|
828
829
|
if jobId then
|
|
829
|
-
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
830
|
-
opts)
|
|
830
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
831
|
+
limiterDuration, markerKey, opts)
|
|
831
832
|
end
|
|
832
833
|
end
|
|
833
834
|
-- Return the timestamp for the next delayed job if any.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAo1Bf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -86,20 +86,20 @@ end
|
|
|
86
86
|
(since an empty list and !EXISTS are not really the same).
|
|
87
87
|
]]
|
|
88
88
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
89
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
89
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
90
90
|
if queueAttributes[1] then
|
|
91
|
-
return pausedKey, true
|
|
91
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
92
92
|
else
|
|
93
93
|
if queueAttributes[2] then
|
|
94
94
|
local activeCount = rcall("LLEN", activeKey)
|
|
95
95
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
96
|
-
return waitKey, true
|
|
96
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
97
97
|
else
|
|
98
|
-
return waitKey, false
|
|
98
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
|
-
return waitKey, false
|
|
102
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
103
103
|
end
|
|
104
104
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
105
105
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -62,20 +62,20 @@ end
|
|
|
62
62
|
(since an empty list and !EXISTS are not really the same).
|
|
63
63
|
]]
|
|
64
64
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
65
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
65
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
66
66
|
if queueAttributes[1] then
|
|
67
|
-
return pausedKey, true
|
|
67
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
68
68
|
else
|
|
69
69
|
if queueAttributes[2] then
|
|
70
70
|
local activeCount = rcall("LLEN", activeKey)
|
|
71
71
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
72
|
-
return waitKey, true
|
|
72
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
73
73
|
else
|
|
74
|
-
return waitKey, false
|
|
74
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
-
return waitKey, false
|
|
78
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
79
79
|
end
|
|
80
80
|
if rcall("ZREM", KEYS[1], jobId) == 1 then
|
|
81
81
|
local jobKey = ARGV[1] .. jobId
|
|
@@ -55,20 +55,20 @@ end
|
|
|
55
55
|
(since an empty list and !EXISTS are not really the same).
|
|
56
56
|
]]
|
|
57
57
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
58
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
58
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
59
59
|
if queueAttributes[1] then
|
|
60
|
-
return pausedKey, true
|
|
60
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
61
61
|
else
|
|
62
62
|
if queueAttributes[2] then
|
|
63
63
|
local activeCount = rcall("LLEN", activeKey)
|
|
64
64
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
65
|
-
return waitKey, true
|
|
65
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
66
66
|
else
|
|
67
|
-
return waitKey, false
|
|
67
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
-
return waitKey, false
|
|
71
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
72
72
|
end
|
|
73
73
|
--[[
|
|
74
74
|
Function to remove job keys.
|
|
@@ -170,20 +170,20 @@ end
|
|
|
170
170
|
(since an empty list and !EXISTS are not really the same).
|
|
171
171
|
]]
|
|
172
172
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
173
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
173
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
174
174
|
if queueAttributes[1] then
|
|
175
|
-
return pausedKey, true
|
|
175
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
176
176
|
else
|
|
177
177
|
if queueAttributes[2] then
|
|
178
178
|
local activeCount = rcall("LLEN", activeKey)
|
|
179
179
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
180
|
-
return waitKey, true
|
|
180
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
181
181
|
else
|
|
182
|
-
return waitKey, false
|
|
182
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
|
-
return waitKey, false
|
|
186
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
187
187
|
end
|
|
188
188
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
189
189
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -138,20 +138,20 @@ end
|
|
|
138
138
|
(since an empty list and !EXISTS are not really the same).
|
|
139
139
|
]]
|
|
140
140
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
141
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
141
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
142
142
|
if queueAttributes[1] then
|
|
143
|
-
return pausedKey, true
|
|
143
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
144
144
|
else
|
|
145
145
|
if queueAttributes[2] then
|
|
146
146
|
local activeCount = rcall("LLEN", activeKey)
|
|
147
147
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
148
|
-
return waitKey, true
|
|
148
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
149
149
|
else
|
|
150
|
-
return waitKey, false
|
|
150
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
151
151
|
end
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
|
-
return waitKey, false
|
|
154
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
155
155
|
end
|
|
156
156
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
157
157
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -55,20 +55,20 @@ end
|
|
|
55
55
|
(since an empty list and !EXISTS are not really the same).
|
|
56
56
|
]]
|
|
57
57
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
58
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
58
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
59
59
|
if queueAttributes[1] then
|
|
60
|
-
return pausedKey, true
|
|
60
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
61
61
|
else
|
|
62
62
|
if queueAttributes[2] then
|
|
63
63
|
local activeCount = rcall("LLEN", activeKey)
|
|
64
64
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
65
|
-
return waitKey, true
|
|
65
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
66
66
|
else
|
|
67
|
-
return waitKey, false
|
|
67
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
-
return waitKey, false
|
|
71
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
72
72
|
end
|
|
73
73
|
local jobKey = KEYS[1]
|
|
74
74
|
if rcall("EXISTS", jobKey) == 1 then
|
|
@@ -80,20 +80,20 @@ end
|
|
|
80
80
|
(since an empty list and !EXISTS are not really the same).
|
|
81
81
|
]]
|
|
82
82
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
83
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
83
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
84
84
|
if queueAttributes[1] then
|
|
85
|
-
return pausedKey, true
|
|
85
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
86
86
|
else
|
|
87
87
|
if queueAttributes[2] then
|
|
88
88
|
local activeCount = rcall("LLEN", activeKey)
|
|
89
89
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
90
|
-
return waitKey, true
|
|
90
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
91
91
|
else
|
|
92
|
-
return waitKey, false
|
|
92
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
|
-
return waitKey, false
|
|
96
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
97
97
|
end
|
|
98
98
|
--[[
|
|
99
99
|
Function to check if queue is paused or maxed
|