mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 16:56:16 +08:00
fix(proxy): wire AppProxyConfig.max_retries into request forwarder
The UI has exposed "请求失败时的重试次数 (0-10, default 3)" since the auto-failover panel was added, but the value was silently dropped — RequestForwarder never received it and the per-provider loop walked the whole list regardless. From the user's perspective the setting was inert. Thread AppProxyConfig.max_retries through create_forwarder into RequestForwarder, derive max_attempts = max_retries + 1 (so max_retries=0 matches the UI copy "0 retries" = single attempt), and break the loop once attempts hit the cap. The check is placed before the circuit breaker allow-permit so an over-cap iteration does not waste a HalfOpen probe slot. When auto-failover is disabled we also force max_retries to 0, mirroring how timeouts already bypass in that mode — "no failover" should mean "one provider, one try", not "limited retries against the same list".
This commit is contained in:
@@ -211,6 +211,13 @@ impl RequestContext {
|
||||
(0, 0, 0)
|
||||
};
|
||||
|
||||
// 故障转移关闭时强制 max_retries=0(仅尝试 1 个 provider),与「不超时 + 不切换」语义一致。
|
||||
let max_retries = if self.app_config.auto_failover_enabled {
|
||||
self.app_config.max_retries
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
RequestForwarder::new(
|
||||
state.provider_router.clone(),
|
||||
non_streaming_timeout,
|
||||
@@ -227,6 +234,7 @@ impl RequestContext {
|
||||
self.rectifier_config.clone(),
|
||||
self.optimizer_config.clone(),
|
||||
self.copilot_optimizer_config.clone(),
|
||||
max_retries,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user