bullmq 5.59.0 → 5.61.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 +16 -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/classes/worker.js +5 -8
- package/dist/cjs/classes/worker.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 +10 -0
- package/dist/esm/classes/queue.js +16 -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/classes/worker.js +5 -8
- package/dist/esm/classes/worker.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
|
@@ -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
|
|
@@ -174,20 +174,20 @@ end
|
|
|
174
174
|
(since an empty list and !EXISTS are not really the same).
|
|
175
175
|
]]
|
|
176
176
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
177
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
177
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
178
178
|
if queueAttributes[1] then
|
|
179
|
-
return pausedKey, true
|
|
179
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
180
180
|
else
|
|
181
181
|
if queueAttributes[2] then
|
|
182
182
|
local activeCount = rcall("LLEN", activeKey)
|
|
183
183
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
184
|
-
return waitKey, true
|
|
184
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
185
185
|
else
|
|
186
|
-
return waitKey, false
|
|
186
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
end
|
|
190
|
-
return waitKey, false
|
|
190
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
191
191
|
end
|
|
192
192
|
--[[
|
|
193
193
|
Function to add job in target list and add marker if needed.
|