style: format M2.5 breaker changes
This commit is contained in:
@@ -79,7 +79,9 @@ end
|
||||
# KEYS: provider_hash(CHS :110-143 + M2.5 窗口/衰减)
|
||||
# ARGV: expected_epoch is_probe probe_owner count_attempt half_window_ms cooldown_ms max_cooldown_ms
|
||||
# 返回: applied state epoch failures retry_after_ms
|
||||
RECORD_SUCCESS = _WINDOW_HELPERS + """
|
||||
RECORD_SUCCESS = (
|
||||
_WINDOW_HELPERS
|
||||
+ """
|
||||
local t = redis.call('TIME')
|
||||
local now = tonumber(t[1]) * 1000 + math.floor(tonumber(t[2]) / 1000)
|
||||
local state = redis.call('HGET', KEYS[1], 'state') or 'closed'
|
||||
@@ -127,12 +129,15 @@ elseif state == 'half_open' then
|
||||
end
|
||||
return {0, state, epoch, failures, math.max(deadline - now, 0)}
|
||||
"""
|
||||
)
|
||||
|
||||
# KEYS: provider_hash(CHS :148-199 + M2.5 双通道/退避)
|
||||
# ARGV: expected_epoch is_probe probe_owner force_open threshold cooldown_ms
|
||||
# rate_limited min_calls fail_rate half_window_ms max_cooldown_ms
|
||||
# 返回: applied state epoch failures retry_after_ms
|
||||
RECORD_FAILURE = _WINDOW_HELPERS + """
|
||||
RECORD_FAILURE = (
|
||||
_WINDOW_HELPERS
|
||||
+ """
|
||||
local t = redis.call('TIME')
|
||||
local now = tonumber(t[1]) * 1000 + math.floor(tonumber(t[2]) / 1000)
|
||||
local state = redis.call('HGET', KEYS[1], 'state') or 'closed'
|
||||
@@ -221,6 +226,7 @@ redis.call('HSET', KEYS[1],
|
||||
'probe_until', 0)
|
||||
return {1, 'closed', epoch, failures, 0}
|
||||
"""
|
||||
)
|
||||
|
||||
# KEYS: provider_hash ; ARGV: expected_epoch probe_owner(CHS :203-225)
|
||||
# 返回: applied state epoch failures retry_after_ms
|
||||
@@ -362,7 +368,12 @@ class RedisGate:
|
||||
) -> GateUpdate:
|
||||
args = self._entry_args(entry)
|
||||
args.extend(
|
||||
[1 if count_attempt else 0, self._half_window_ms, self._cooldown_ms, self._max_cooldown_ms]
|
||||
[
|
||||
1 if count_attempt else 0,
|
||||
self._half_window_ms,
|
||||
self._cooldown_ms,
|
||||
self._max_cooldown_ms,
|
||||
]
|
||||
)
|
||||
try:
|
||||
result = await self._success_lua(keys=[self._key(entry.source_name)], args=args)
|
||||
|
||||
@@ -130,9 +130,7 @@ class TestResilienceKeys:
|
||||
s = GatewaySettings.from_env("LLM", env=_env())
|
||||
assert s.selector == "health_aware" and s.quota_full == "wait"
|
||||
assert (
|
||||
GatewaySettings.from_env(
|
||||
"LLM", env=_env(**{"LLM__SELECTOR": "round_robin"})
|
||||
).selector
|
||||
GatewaySettings.from_env("LLM", env=_env(**{"LLM__SELECTOR": "round_robin"})).selector
|
||||
== "round_robin"
|
||||
)
|
||||
s2 = GatewaySettings.from_env(
|
||||
|
||||
Reference in New Issue
Block a user