Skip to main content

SessionPromotion

Struct SessionPromotion 

Source
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: u32

Failure count that triggers promotion.

§window: String

Sliding 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: u32

Re-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: usize

Hard 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

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionPromotion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SessionPromotion

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.