bullmq 1.75.0 → 1.75.1
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.
@@ -55,16 +55,26 @@ if jobId then
|
|
55
55
|
if(maxJobs) then
|
56
56
|
local rateLimiterKey = KEYS[6];
|
57
57
|
|
58
|
+
local groupKey
|
58
59
|
if(ARGV[8]) then
|
59
|
-
|
60
|
-
if groupKey ~=
|
60
|
+
groupKey = string.match(jobId, "[^:]+$")
|
61
|
+
if groupKey ~= jobId then
|
61
62
|
rateLimiterKey = rateLimiterKey .. ":" .. groupKey
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
local jobCounter
|
66
|
+
local jobCounter
|
67
|
+
|
68
|
+
if groupKey ~= nil then
|
69
|
+
if rateLimiterKey ~= KEYS[6] then
|
70
|
+
jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
71
|
+
end
|
72
|
+
else
|
73
|
+
jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
74
|
+
end
|
75
|
+
|
66
76
|
-- check if rate limit hit
|
67
|
-
if jobCounter > maxJobs then
|
77
|
+
if jobCounter ~= nil and jobCounter > maxJobs then
|
68
78
|
local exceedingJobs = jobCounter - maxJobs
|
69
79
|
local expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
70
80
|
local delay = expireTime + ((exceedingJobs - 1) * ARGV[7]) / maxJobs;
|
@@ -55,16 +55,26 @@ if jobId then
|
|
55
55
|
if(maxJobs) then
|
56
56
|
local rateLimiterKey = KEYS[6];
|
57
57
|
|
58
|
+
local groupKey
|
58
59
|
if(ARGV[8]) then
|
59
|
-
|
60
|
-
if groupKey ~=
|
60
|
+
groupKey = string.match(jobId, "[^:]+$")
|
61
|
+
if groupKey ~= jobId then
|
61
62
|
rateLimiterKey = rateLimiterKey .. ":" .. groupKey
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
local jobCounter
|
66
|
+
local jobCounter
|
67
|
+
|
68
|
+
if groupKey ~= nil then
|
69
|
+
if rateLimiterKey ~= KEYS[6] then
|
70
|
+
jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
71
|
+
end
|
72
|
+
else
|
73
|
+
jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
74
|
+
end
|
75
|
+
|
66
76
|
-- check if rate limit hit
|
67
|
-
if jobCounter > maxJobs then
|
77
|
+
if jobCounter ~= nil and jobCounter > maxJobs then
|
68
78
|
local exceedingJobs = jobCounter - maxJobs
|
69
79
|
local expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
70
80
|
local delay = expireTime + ((exceedingJobs - 1) * ARGV[7]) / maxJobs;
|