pub struct SessionPromoter { /* private fields */ }Expand description
Tracks which sessions have earned a higher starting rung.
Keyed by (tenant, session): a session id is only unique inside a tenant, and a promotion must
never cross that boundary — one tenant’s traffic pattern is not a fact about another’s.
Implementations§
Source§impl SessionPromoter
impl SessionPromoter
Sourcepub fn new(cfg: SessionPromotion) -> Result<Self>
pub fn new(cfg: SessionPromotion) -> Result<Self>
Build from config. window doubles as the idle TTL.
§Errors
firstpass_core::Error::BadDuration when window is not <int><unit>.
Back this promoter with a shared store, so a session keeps its rung across replicas.
Sourcepub async fn decide_async(
&self,
tenant: &str,
session: &str,
now: Instant,
) -> Decision
pub async fn decide_async( &self, tenant: &str, session: &str, now: Instant, ) -> Decision
Where this request should start.
Sourcepub async fn record_async(
&self,
tenant: &str,
session: &str,
served_rung: u32,
escalated: bool,
now: Instant,
)
pub async fn record_async( &self, tenant: &str, session: &str, served_rung: u32, escalated: bool, now: Instant, )
Record how a request ended, against wherever this promoter’s state lives.
Read-modify-write, so two replicas handling concurrent turns of one session can lose an increment — last write wins. The cost is a promotion arriving one turn late, which is one extra cheap-rung call; the gate still verifies whatever is served, so it cannot affect correctness.
Trait Implementations§
Source§impl Debug for SessionPromoter
impl Debug for SessionPromoter
Source§impl PromotionStore for SessionPromoter
impl PromotionStore for SessionPromoter
Auto Trait Implementations§
impl !Freeze for SessionPromoter
impl !RefUnwindSafe for SessionPromoter
impl !UnwindSafe for SessionPromoter
impl Send for SessionPromoter
impl Sync for SessionPromoter
impl Unpin for SessionPromoter
impl UnsafeUnpin for SessionPromoter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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