bullmq 5.58.9 → 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/child-pool.js +8 -1
- package/dist/cjs/classes/child-pool.js.map +1 -1
- 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/classes/worker.js +42 -30
- 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/deduplicateJob.lua +53 -20
- package/dist/cjs/commands/includes/getTargetQueueList.lua +5 -5
- package/dist/cjs/commands/includes/prepareJobForProcessing.lua +2 -4
- package/dist/cjs/commands/moveJobFromActiveToWait-9.lua +1 -1
- package/dist/cjs/commands/moveStalledJobsToWait-8.lua +0 -1
- package/dist/cjs/commands/moveToActive-11.lua +7 -4
- package/dist/cjs/commands/moveToDelayed-8.lua +2 -1
- package/dist/cjs/commands/moveToFinished-14.lua +10 -7
- package/dist/cjs/scripts/addDelayedJob-6.js +52 -23
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addJobScheduler-11.js +5 -5
- package/dist/cjs/scripts/addParentJob-5.js +52 -23
- package/dist/cjs/scripts/addParentJob-5.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-9.js +52 -23
- package/dist/cjs/scripts/addPrioritizedJob-9.js.map +1 -1
- package/dist/cjs/scripts/addRepeatableJob-2.js +5 -5
- package/dist/cjs/scripts/addStandardJob-9.js +52 -23
- package/dist/cjs/scripts/addStandardJob-9.js.map +1 -1
- 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 +6 -6
- 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/moveToDelayed-8.js +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/child-pool.js +8 -1
- package/dist/esm/classes/child-pool.js.map +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/classes/worker.d.ts +1 -0
- package/dist/esm/classes/worker.js +42 -30
- 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/deduplicateJob.lua +53 -20
- package/dist/esm/commands/includes/getTargetQueueList.lua +5 -5
- package/dist/esm/commands/includes/prepareJobForProcessing.lua +2 -4
- package/dist/esm/commands/moveJobFromActiveToWait-9.lua +1 -1
- package/dist/esm/commands/moveStalledJobsToWait-8.lua +0 -1
- package/dist/esm/commands/moveToActive-11.lua +7 -4
- package/dist/esm/commands/moveToDelayed-8.lua +2 -1
- package/dist/esm/commands/moveToFinished-14.lua +10 -7
- package/dist/esm/interfaces/base-job-options.d.ts +1 -1
- package/dist/esm/interfaces/worker-options.d.ts +8 -0
- package/dist/esm/scripts/addDelayedJob-6.js +52 -23
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addJobScheduler-11.js +5 -5
- package/dist/esm/scripts/addParentJob-5.js +52 -23
- package/dist/esm/scripts/addParentJob-5.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-9.js +52 -23
- package/dist/esm/scripts/addPrioritizedJob-9.js.map +1 -1
- package/dist/esm/scripts/addRepeatableJob-2.js +5 -5
- package/dist/esm/scripts/addStandardJob-9.js +52 -23
- package/dist/esm/scripts/addStandardJob-9.js.map +1 -1
- 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 +6 -6
- 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/moveToDelayed-8.js +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
|
@@ -137,20 +137,20 @@ end
|
|
|
137
137
|
(since an empty list and !EXISTS are not really the same).
|
|
138
138
|
]]
|
|
139
139
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
140
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
140
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
141
141
|
if queueAttributes[1] then
|
|
142
|
-
return pausedKey, true
|
|
142
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
143
143
|
else
|
|
144
144
|
if queueAttributes[2] then
|
|
145
145
|
local activeCount = rcall("LLEN", activeKey)
|
|
146
146
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
147
|
-
return waitKey, true
|
|
147
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
148
148
|
else
|
|
149
|
-
return waitKey, false
|
|
149
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
152
|
end
|
|
153
|
-
return waitKey, false
|
|
153
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
154
154
|
end
|
|
155
155
|
--[[
|
|
156
156
|
Function to move job from prioritized state to active.
|
|
@@ -538,20 +538,19 @@ end
|
|
|
538
538
|
]]
|
|
539
539
|
-- Includes
|
|
540
540
|
local function prepareJobForProcessing(keyPrefix, rateLimiterKey, eventStreamKey,
|
|
541
|
-
jobId, processedOn, maxJobs, markerKey, opts)
|
|
541
|
+
jobId, processedOn, maxJobs, limiterDuration, markerKey, opts)
|
|
542
542
|
local jobKey = keyPrefix .. jobId
|
|
543
543
|
-- Check if we need to perform rate limiting.
|
|
544
544
|
if maxJobs then
|
|
545
545
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
|
546
546
|
if jobCounter == 1 then
|
|
547
|
-
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
|
548
547
|
local integerDuration = math.floor(math.abs(limiterDuration))
|
|
549
548
|
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
|
550
549
|
end
|
|
551
550
|
end
|
|
552
|
-
local lockKey = jobKey .. ':lock'
|
|
553
551
|
-- get a lock
|
|
554
552
|
if opts['token'] ~= "0" then
|
|
553
|
+
local lockKey = jobKey .. ':lock'
|
|
555
554
|
rcall("SET", lockKey, opts['token'], "PX", opts['lockDuration'])
|
|
556
555
|
end
|
|
557
556
|
local optionalValues = {}
|
|
@@ -789,12 +788,13 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
789
788
|
-- Try to get next job to avoid an extra roundtrip if the queue is not closing,
|
|
790
789
|
-- and not rate limited.
|
|
791
790
|
if (ARGV[6] == "1") then
|
|
792
|
-
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2],
|
|
791
|
+
local target, isPausedOrMaxed, rateLimitMax, rateLimitDuration = getTargetQueueList(metaKey, KEYS[2],
|
|
792
|
+
KEYS[1], KEYS[8])
|
|
793
793
|
local markerKey = KEYS[14]
|
|
794
794
|
-- Check if there are delayed jobs that can be promoted
|
|
795
795
|
promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[3], eventStreamKey, prefix, timestamp, KEYS[10],
|
|
796
796
|
isPausedOrMaxed)
|
|
797
|
-
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
|
797
|
+
local maxJobs = tonumber(rateLimitMax or (opts['limiter'] and opts['limiter']['max']))
|
|
798
798
|
-- Check if we are rate limited first.
|
|
799
799
|
local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
|
|
800
800
|
if expireTime > 0 then
|
|
@@ -804,6 +804,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
804
804
|
if isPausedOrMaxed then
|
|
805
805
|
return {0, 0, 0, 0}
|
|
806
806
|
end
|
|
807
|
+
local limiterDuration = (opts['limiter'] and opts['limiter']['duration']) or rateLimitDuration
|
|
807
808
|
jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
|
|
808
809
|
if jobId then
|
|
809
810
|
-- Markers in waitlist DEPRECATED in v5: Remove in v6.
|
|
@@ -814,17 +815,17 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
|
814
815
|
if jobId == "0:0" then
|
|
815
816
|
jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])
|
|
816
817
|
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
817
|
-
markerKey, opts)
|
|
818
|
+
limiterDuration, markerKey, opts)
|
|
818
819
|
end
|
|
819
820
|
else
|
|
820
|
-
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
821
|
-
opts)
|
|
821
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
822
|
+
limiterDuration, markerKey, opts)
|
|
822
823
|
end
|
|
823
824
|
else
|
|
824
825
|
jobId = moveJobFromPrioritizedToActive(KEYS[3], KEYS[2], KEYS[10])
|
|
825
826
|
if jobId then
|
|
826
|
-
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
827
|
-
opts)
|
|
827
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
|
828
|
+
limiterDuration, markerKey, opts)
|
|
828
829
|
end
|
|
829
830
|
end
|
|
830
831
|
-- 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;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -83,20 +83,20 @@ end
|
|
|
83
83
|
(since an empty list and !EXISTS are not really the same).
|
|
84
84
|
]]
|
|
85
85
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
86
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
86
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
87
87
|
if queueAttributes[1] then
|
|
88
|
-
return pausedKey, true
|
|
88
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
89
89
|
else
|
|
90
90
|
if queueAttributes[2] then
|
|
91
91
|
local activeCount = rcall("LLEN", activeKey)
|
|
92
92
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
93
|
-
return waitKey, true
|
|
93
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
94
94
|
else
|
|
95
|
-
return waitKey, false
|
|
95
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
|
-
return waitKey, false
|
|
99
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
100
100
|
end
|
|
101
101
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
102
102
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -59,20 +59,20 @@ end
|
|
|
59
59
|
(since an empty list and !EXISTS are not really the same).
|
|
60
60
|
]]
|
|
61
61
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
62
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
62
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
63
63
|
if queueAttributes[1] then
|
|
64
|
-
return pausedKey, true
|
|
64
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
65
65
|
else
|
|
66
66
|
if queueAttributes[2] then
|
|
67
67
|
local activeCount = rcall("LLEN", activeKey)
|
|
68
68
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
69
|
-
return waitKey, true
|
|
69
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
70
70
|
else
|
|
71
|
-
return waitKey, false
|
|
71
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
|
-
return waitKey, false
|
|
75
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
76
76
|
end
|
|
77
77
|
if rcall("ZREM", KEYS[1], jobId) == 1 then
|
|
78
78
|
local jobKey = ARGV[1] .. jobId
|
|
@@ -52,20 +52,20 @@ end
|
|
|
52
52
|
(since an empty list and !EXISTS are not really the same).
|
|
53
53
|
]]
|
|
54
54
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
55
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
55
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
56
56
|
if queueAttributes[1] then
|
|
57
|
-
return pausedKey, true
|
|
57
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
58
58
|
else
|
|
59
59
|
if queueAttributes[2] then
|
|
60
60
|
local activeCount = rcall("LLEN", activeKey)
|
|
61
61
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
62
|
-
return waitKey, true
|
|
62
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
63
63
|
else
|
|
64
|
-
return waitKey, false
|
|
64
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
|
-
return waitKey, false
|
|
68
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
69
69
|
end
|
|
70
70
|
--[[
|
|
71
71
|
Function to remove job keys.
|
|
@@ -167,20 +167,20 @@ end
|
|
|
167
167
|
(since an empty list and !EXISTS are not really the same).
|
|
168
168
|
]]
|
|
169
169
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
170
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
170
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
171
171
|
if queueAttributes[1] then
|
|
172
|
-
return pausedKey, true
|
|
172
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
173
173
|
else
|
|
174
174
|
if queueAttributes[2] then
|
|
175
175
|
local activeCount = rcall("LLEN", activeKey)
|
|
176
176
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
177
|
-
return waitKey, true
|
|
177
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
178
178
|
else
|
|
179
|
-
return waitKey, false
|
|
179
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
182
|
end
|
|
183
|
-
return waitKey, false
|
|
183
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
184
184
|
end
|
|
185
185
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
186
186
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -135,20 +135,20 @@ end
|
|
|
135
135
|
(since an empty list and !EXISTS are not really the same).
|
|
136
136
|
]]
|
|
137
137
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
138
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
138
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
139
139
|
if queueAttributes[1] then
|
|
140
|
-
return pausedKey, true
|
|
140
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
141
141
|
else
|
|
142
142
|
if queueAttributes[2] then
|
|
143
143
|
local activeCount = rcall("LLEN", activeKey)
|
|
144
144
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
145
|
-
return waitKey, true
|
|
145
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
146
146
|
else
|
|
147
|
-
return waitKey, false
|
|
147
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
|
-
return waitKey, false
|
|
151
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
152
152
|
end
|
|
153
153
|
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
154
154
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
|
@@ -52,20 +52,20 @@ end
|
|
|
52
52
|
(since an empty list and !EXISTS are not really the same).
|
|
53
53
|
]]
|
|
54
54
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
55
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
55
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
56
56
|
if queueAttributes[1] then
|
|
57
|
-
return pausedKey, true
|
|
57
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
58
58
|
else
|
|
59
59
|
if queueAttributes[2] then
|
|
60
60
|
local activeCount = rcall("LLEN", activeKey)
|
|
61
61
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
62
|
-
return waitKey, true
|
|
62
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
63
63
|
else
|
|
64
|
-
return waitKey, false
|
|
64
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
|
-
return waitKey, false
|
|
68
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
69
69
|
end
|
|
70
70
|
local jobKey = KEYS[1]
|
|
71
71
|
if rcall("EXISTS", jobKey) == 1 then
|
|
@@ -77,20 +77,20 @@ end
|
|
|
77
77
|
(since an empty list and !EXISTS are not really the same).
|
|
78
78
|
]]
|
|
79
79
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
80
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
80
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
81
81
|
if queueAttributes[1] then
|
|
82
|
-
return pausedKey, true
|
|
82
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
83
83
|
else
|
|
84
84
|
if queueAttributes[2] then
|
|
85
85
|
local activeCount = rcall("LLEN", activeKey)
|
|
86
86
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
87
|
-
return waitKey, true
|
|
87
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
88
88
|
else
|
|
89
|
-
return waitKey, false
|
|
89
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
|
-
return waitKey, false
|
|
93
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
94
94
|
end
|
|
95
95
|
--[[
|
|
96
96
|
Function to check if queue is paused or maxed
|
|
@@ -171,20 +171,20 @@ end
|
|
|
171
171
|
(since an empty list and !EXISTS are not really the same).
|
|
172
172
|
]]
|
|
173
173
|
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
174
|
-
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
|
174
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency", "max", "duration")
|
|
175
175
|
if queueAttributes[1] then
|
|
176
|
-
return pausedKey, true
|
|
176
|
+
return pausedKey, true, queueAttributes[3], queueAttributes[4]
|
|
177
177
|
else
|
|
178
178
|
if queueAttributes[2] then
|
|
179
179
|
local activeCount = rcall("LLEN", activeKey)
|
|
180
180
|
if activeCount >= tonumber(queueAttributes[2]) then
|
|
181
|
-
return waitKey, true
|
|
181
|
+
return waitKey, true, queueAttributes[3], queueAttributes[4]
|
|
182
182
|
else
|
|
183
|
-
return waitKey, false
|
|
183
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
|
-
return waitKey, false
|
|
187
|
+
return waitKey, false, queueAttributes[3], queueAttributes[4]
|
|
188
188
|
end
|
|
189
189
|
--[[
|
|
190
190
|
Function to add job in target list and add marker if needed.
|