@@ -116,13 +116,13 @@ local function __gateReconcile(setKey, msgKeyPrefix, reconcileKeyPrefix)
116116 end
117117end
118118
119- local function __gatesHaveCapacity(gatesKeyPrefix, msg, messageId, envLimit, msgKeyPrefix)
119+ local function __gatesHaveCapacity(gatesKeyPrefix, msg, messageId, envLimit, msgKeyPrefix, ckOverridesEnabled )
120120 if not msg.gates then return true end
121121 for _, gate in ipairs(msg.gates) do
122122 local base, variant, gateKey = __gateKeys(gatesKeyPrefix, msg, gate)
123123 local occupancy = tonumber(redis.call('SCARD', variant .. ':currentConcurrency') or '0')
124124 local perKeyLimit = math.min(tonumber(redis.call('GET', base .. ':concurrency') or '1000000'), envLimit)
125- if gateKey and gateKey ~= '' then
125+ if ckOverridesEnabled and gateKey and gateKey ~= '' then
126126 local gateOverride = redis.call('HGET', base .. ':ckLimits', string.sub(variant, #gatesKeyPrefix + 1))
127127 if gateOverride then
128128 perKeyLimit = math.min(tonumber(gateOverride), envLimit)
@@ -2571,6 +2571,7 @@ export class RunQueue {
25712571 enableFastPathArg ,
25722572 this . options . redis . keyPrefix ?? "" ,
25732573 this . options . gatesEnabled ? "1" : "0" ,
2574+ this . options . totalConcurrencyEnabled ? "1" : "0" ,
25742575 metricsGaugeArg
25752576 ) ;
25762577 } else {
@@ -2600,6 +2601,7 @@ export class RunQueue {
26002601 enableFastPathArg ,
26012602 this . options . redis . keyPrefix ?? "" ,
26022603 this . options . gatesEnabled ? "1" : "0" ,
2604+ this . options . totalConcurrencyEnabled ? "1" : "0" ,
26032605 metricsGaugeArg
26042606 ) ;
26052607 }
@@ -2681,6 +2683,7 @@ export class RunQueue {
26812683 this . options . redis . keyPrefix ?? "" ,
26822684 String ( maxCount ) ,
26832685 this . options . gatesEnabled ? "1" : "0" ,
2686+ this . options . totalConcurrencyEnabled ? "1" : "0" ,
26842687 metricsGaugeArg
26852688 ) ;
26862689
@@ -3678,6 +3681,7 @@ local currentTime = ARGV[8]
36783681local enableFastPath = ARGV[9]
36793682local keyPrefix = ARGV[10]
36803683local gatesEnabled = ARGV[11] == '1'
3684+ local totalConcurrencyEnabled = ARGV[12] == '1'
36813685
36823686${ QUEUE_METRICS_GAUGE_PRELUDE }
36833687${ QUEUE_GATES_LUA_HELPERS }
@@ -3705,7 +3709,7 @@ if enableFastPath == '1' then
37053709 local okDecode, decoded = pcall(cjson.decode, messageData)
37063710 if okDecode and type(decoded) == 'table' and decoded.gates then
37073711 gateMsg = decoded
3708- gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil)
3712+ gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil, totalConcurrencyEnabled )
37093713 end
37103714 end
37113715
@@ -3792,6 +3796,7 @@ local currentTime = ARGV[10]
37923796local enableFastPath = ARGV[11]
37933797local keyPrefix = ARGV[12]
37943798local gatesEnabled = ARGV[13] == '1'
3799+ local totalConcurrencyEnabled = ARGV[14] == '1'
37953800
37963801${ QUEUE_METRICS_GAUGE_PRELUDE }
37973802${ QUEUE_GATES_LUA_HELPERS }
@@ -3819,7 +3824,7 @@ if enableFastPath == '1' then
38193824 local okDecode, decoded = pcall(cjson.decode, messageData)
38203825 if okDecode and type(decoded) == 'table' and decoded.gates then
38213826 gateMsg = decoded
3822- gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil)
3827+ gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil, totalConcurrencyEnabled )
38233828 end
38243829 end
38253830
@@ -4186,7 +4191,7 @@ if enableFastPath == '1' then
41864191 local okDecode, decoded = pcall(cjson.decode, messageData)
41874192 if okDecode and type(decoded) == 'table' and decoded.gates then
41884193 gateMsg = decoded
4189- gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil)
4194+ gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil, totalConcurrencyEnabled )
41904195 end
41914196 end
41924197
@@ -4364,7 +4369,7 @@ if enableFastPath == '1' then
43644369 local okDecode, decoded = pcall(cjson.decode, messageData)
43654370 if okDecode and type(decoded) == 'table' and decoded.gates then
43664371 gateMsg = decoded
4367- gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil)
4372+ gatesAllowFastPath = __gatesHaveCapacity(keyPrefix, decoded, messageId, envLimit, nil, totalConcurrencyEnabled )
43684373 end
43694374 end
43704375
@@ -4694,6 +4699,7 @@ local defaultEnvConcurrencyBurstFactor = ARGV[4]
46944699local keyPrefix = ARGV[5]
46954700local maxCount = tonumber(ARGV[6] or '1')
46964701local gatesEnabled = ARGV[7] == '1'
4702+ local totalConcurrencyEnabled = ARGV[8] == '1'
46974703${ QUEUE_METRICS_GAUGE_PRELUDE }
46984704${ QUEUE_GATES_LUA_HELPERS }
46994705${ QUEUE_METRICS_GAUGE_LUA }
@@ -4766,7 +4772,7 @@ for i = 1, #messages, 2 do
47664772 else
47674773 local gatesAllow = true
47684774 if gatesEnabled then
4769- gatesAllow = __gatesHaveCapacity(keyPrefix, messageData, messageId, envConcurrencyLimit, messageKeyPrefix)
4775+ gatesAllow = __gatesHaveCapacity(keyPrefix, messageData, messageId, envConcurrencyLimit, messageKeyPrefix, totalConcurrencyEnabled )
47704776 end
47714777
47724778 if gatesAllow then
@@ -5115,7 +5121,7 @@ for _, ckQueueName in ipairs(ckQueues) do
51155121 else
51165122 local gatesAllow = true
51175123 if gatesEnabled then
5118- gatesAllow = __gatesHaveCapacity(keyPrefix, messageData, messageId, envConcurrencyLimit, messageKeyPrefix)
5124+ gatesAllow = __gatesHaveCapacity(keyPrefix, messageData, messageId, envConcurrencyLimit, messageKeyPrefix, totalConcurrencyEnabled )
51195125 end
51205126 if not gatesAllow then
51215127 blockedByGates = true
@@ -6223,6 +6229,7 @@ declare module "@internal/redis" {
62236229 enableFastPath : string ,
62246230 keyPrefix : string ,
62256231 gatesEnabled : string ,
6232+ totalConcurrencyEnabled : string ,
62266233 metricsEnabled : string ,
62276234 callback ?: Callback < [ number , number [ ] | null ] >
62286235 ) : Result < [ number , number [ ] | null ] , Context > ;
@@ -6256,6 +6263,7 @@ declare module "@internal/redis" {
62566263 enableFastPath : string ,
62576264 keyPrefix : string ,
62586265 gatesEnabled : string ,
6266+ totalConcurrencyEnabled : string ,
62596267 metricsEnabled : string ,
62606268 callback ?: Callback < [ number , number [ ] | null ] >
62616269 ) : Result < [ number , number [ ] | null ] , Context > ;
@@ -6294,6 +6302,7 @@ declare module "@internal/redis" {
62946302 keyPrefix : string ,
62956303 maxCount : string ,
62966304 gatesEnabled : string ,
6305+ totalConcurrencyEnabled : string ,
62976306 metricsEnabled : string ,
62986307 callback ?: Callback < [ string [ ] | null , number [ ] | null ] >
62996308 ) : Result < [ string [ ] | null , number [ ] | null ] , Context > ;
0 commit comments