#[non_exhaustive]pub struct CircuitBreakerConfig {
pub failure_threshold: u32,
pub cooldown_secs: u64,
pub success_threshold: u32,
pub max_tracked_hosts: usize,
pub host_idle_ttl_secs: u64,
}Expand description
熔断器策略配置。默认关闭——只有在 HttpClientConfig
中显式设置 circuit_breaker: Some(..) 才启用。
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.failure_threshold: u32触发熔断的连续失败次数(Closed 状态下)。
cooldown_secs: u64Open 状态的冷却秒数,冷却后放行一次探测(转 HalfOpen)。
success_threshold: u32HalfOpen 状态下恢复 Closed 所需的连续成功次数。
max_tracked_hosts: usize状态 map 最多保留的 host 数;超出后按最久未活跃淘汰。
host_idle_ttl_secs: u64host 条目空闲多久后可被淘汰(秒)。必须 >= cooldown_secs, 否则已打开的熔断可能在冷却期结束前被遗忘(fail-open)。
Implementations§
Trait Implementations§
Source§impl Clone for CircuitBreakerConfig
impl Clone for CircuitBreakerConfig
Source§impl Debug for CircuitBreakerConfig
impl Debug for CircuitBreakerConfig
Auto Trait Implementations§
impl Forget for CircuitBreakerConfig
impl Freeze for CircuitBreakerConfig
impl Move for CircuitBreakerConfig
impl RefUnwindSafe for CircuitBreakerConfig
impl Send for CircuitBreakerConfig
impl Sync for CircuitBreakerConfig
impl Unpin for CircuitBreakerConfig
impl UnsafeUnpin for CircuitBreakerConfig
impl UnwindSafe for CircuitBreakerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more