v0.34.0_1
This commit is contained in:
1 parent
9b3d6731cc
commit
00f29f92c8
68 files changed
+2599
-513
No files matched your search
+19
-2
@@ -2,6 +2,7 @@ impl BackendState {
|
||||
fn new(mode: HealthMode) -> Self {
|
||||
let now = Instant::now();
|
||||
Self {
|
||||
healthy_cached: AtomicBool::new(mode == HealthMode::Off),
|
||||
health: Mutex::new(Health {
|
||||
healthy: mode == HealthMode::Off,
|
||||
active_healthy: mode == HealthMode::Off,
|
||||
@@ -111,6 +112,11 @@ impl BackendState {
|
||||
}
|
||||
}
|
||||
pub fn healthy(&self) -> bool {
|
||||
// No lock/clock acquisition for a healthy backend. Only an unhealthy
|
||||
// backend enters the quarantine/cooldown recovery path below.
|
||||
if self.healthy_cached.load(Ordering::Acquire) {
|
||||
return true;
|
||||
}
|
||||
let mut h = lock(&self.health);
|
||||
// Passive-only monitoring has no active probes to recover an ejected
|
||||
// backend. After a bounded quarantine, allow one new traffic attempt.
|
||||
@@ -125,6 +131,12 @@ impl BackendState {
|
||||
}
|
||||
h.healthy
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn set_healthy_for_test(&self, healthy: bool) {
|
||||
lock(&self.health).healthy = healthy;
|
||||
self.healthy_cached.store(healthy, Ordering::Release);
|
||||
}
|
||||
|
||||
fn clear_passive_ejection(h: &mut Health) {
|
||||
h.passive_healthy = true;
|
||||
h.passive_failures = 0;
|
||||
@@ -195,6 +207,7 @@ impl BackendState {
|
||||
|
||||
fn finish_transition(&self, h: &mut Health, previous: bool) {
|
||||
h.healthy = h.active_healthy && h.passive_healthy;
|
||||
self.healthy_cached.store(h.healthy, Ordering::Release);
|
||||
if previous != h.healthy {
|
||||
h.transitions = h.transitions.saturating_add(1);
|
||||
if h.healthy {
|
||||
@@ -446,6 +459,10 @@ pub struct Member {
|
||||
pub backend: Arc<CompiledBackend>,
|
||||
pub definition: PoolMember,
|
||||
pub state: Arc<BackendState>,
|
||||
// Immutable effective per-backend policies are compiled once per pool
|
||||
// generation, not deep-cloned for every request/lease.
|
||||
health_settings: Arc<HealthCheck>,
|
||||
passive_settings: Arc<PassiveHealth>,
|
||||
token: String,
|
||||
}
|
||||
#[derive(Debug)]
|
||||
@@ -461,7 +478,7 @@ pub struct Pool {
|
||||
#[derive(Debug)]
|
||||
pub struct Lease {
|
||||
pub member: Arc<Member>,
|
||||
health: HealthCheck,
|
||||
passive_health: PassiveHealth,
|
||||
health: Arc<HealthCheck>,
|
||||
passive_health: Arc<PassiveHealth>,
|
||||
error_recorded: AtomicBool,
|
||||
}
|
||||
Reference in new issue
Block a user