mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
5a5ca2a989
This commit addresses several critical issues in the failover system: **Circuit breaker state persistence (previous fix)** - Promote ProviderRouter to ProxyState for cross-request state sharing - Remove redundant router.rs module - Fix 429 errors to be retryable (rate limiting should try other providers) **Hot-update circuit breaker config** - Add update_circuit_breaker_configs() to ProxyServer and ProxyService - Connect update_circuit_breaker_config command to running circuit breakers - Add reset_provider_circuit_breaker() for manual breaker reset **Fix HalfOpen deadlock bug** - Change half_open_requests from cumulative count to in-flight count - Release quota in record_success()/record_failure() when in HalfOpen state - Prevents permanent deadlock when success_threshold > 1 **Fix duplicate select_providers() call** - Store providers list in RequestContext, pass to forward_with_retry() - Avoid consuming HalfOpen quota twice per request - Single call to select_providers() per request lifecycle **Add per-provider retry with exponential backoff** - Implement forward_with_provider_retry() with configurable max_retries - Backoff delays: 100ms, 200ms, 400ms, etc.
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
//! 代理服务器模块
|
|
//!
|
|
//! 提供本地HTTP代理服务,支持多Provider故障转移和请求透传
|
|
|
|
pub mod circuit_breaker;
|
|
pub mod error;
|
|
mod forwarder;
|
|
pub mod handler_config;
|
|
pub mod handler_context;
|
|
mod handlers;
|
|
mod health;
|
|
pub mod provider_router;
|
|
pub mod providers;
|
|
pub mod response_handler;
|
|
pub mod response_processor;
|
|
pub(crate) mod server;
|
|
pub mod session;
|
|
pub(crate) mod types;
|
|
pub mod usage;
|
|
|
|
// 公开导出给外部使用(commands, services等模块需要)
|
|
#[allow(unused_imports)]
|
|
pub use circuit_breaker::{
|
|
CircuitBreaker, CircuitBreakerConfig, CircuitBreakerStats, CircuitState,
|
|
};
|
|
#[allow(unused_imports)]
|
|
pub use error::ProxyError;
|
|
#[allow(unused_imports)]
|
|
pub use provider_router::ProviderRouter;
|
|
#[allow(unused_imports)]
|
|
pub use response_handler::{NonStreamHandler, ResponseType, StreamHandler};
|
|
#[allow(unused_imports)]
|
|
pub use session::{ClientFormat, ProxySession};
|
|
#[allow(unused_imports)]
|
|
pub use types::{ProxyConfig, ProxyServerInfo, ProxyStatus};
|
|
|
|
// 内部模块间共享(供子模块使用)
|
|
// 注意:这个导出用于模块内部,编译器可能警告未使用但实际被子模块使用
|
|
#[allow(unused_imports)]
|
|
pub(crate) use types::*;
|