pub struct SessionPromotion {
pub after_failures: u32,
pub window: String,
pub probe_every: u32,
pub max_sessions: usize,
pub redis_url: Option<String>,
}Expand description
“After N failures within a window, promote this session’s starting rung.”
Fields§
§after_failures: u32Failure count that triggers promotion.
window: StringSliding window, e.g. "30m". Also the idle TTL: a session untouched for this long forgets
its promotion, so a reused session id never inherits a stale rung.
probe_every: u32Re-probe one rung below the promotion every probe_every turns.
Without this, promotion is a ratchet: a session that escalates once stays expensive for
its whole life, so every later turn — including the trivial ones — pays the higher rung.
The periodic probe is the only way a promotion comes back down. 1 re-probes every turn
(promotion effectively off); large values approach a permanent ratchet.
max_sessions: usizeHard cap on tracked sessions; oldest evicted first. A routing optimisation must never be able to exhaust memory on a proxy under load. In-process only — a Redis-backed store is bounded by its TTL and the server’s own eviction policy, and a per-replica cap on a shared store would have each replica evicting the others’ sessions.
redis_url: Option<String>Redis URL for promotion state shared across replicas. Absent (default) = in-process only.
Without it, promotion fragments behind a load balancer: a session that escalated on one
replica starts cold on the next, so the escalation tax this exists to remove is paid again
on roughly (N-1)/N of turns — configured, reporting nothing wrong, doing a fraction of its
job. Requires the redis-cache build feature.
Implementations§
Source§impl SessionPromotion
impl SessionPromotion
Sourcepub fn window_duration(&self) -> Result<Duration>
pub fn window_duration(&self) -> Result<Duration>
Parse SessionPromotion::window into a Duration.
§Errors
Returns Error::BadDuration if the window is not <int><unit> with unit in s/m/h/d.
Trait Implementations§
Source§impl Clone for SessionPromotion
impl Clone for SessionPromotion
Source§fn clone(&self) -> SessionPromotion
fn clone(&self) -> SessionPromotion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more