SessionRegistry

Struct SessionRegistry 

Source
pub struct SessionRegistry { /* private fields */ }
Expand description

Session registry:

  • session_key -> Connection
  • user_key -> {session_key...}
  • tenant_id -> count (Atomic)

Implementations§

Source§

impl SessionRegistry

Source

pub fn new() -> SessionRegistry

Source

pub fn try_insert( &self, tenant_id: String, user_key: String, session_key: String, conn: Connection, max_total: u64, ) -> Result<(), WsPrismError>

Insert a session while enforcing a tenant-wide cap (best-effort).

Concurrency note: For throughput, this uses lock-free atomics plus an optimistic increment/check pattern. Under extreme contention, a small temporary overshoot of max_total is possible before the counter is corrected. This is an intentional trade-off to avoid global locks.

Source

pub fn remove_session( &self, user_key: &str, session_key: &str, ) -> Option<Connection>

Source

pub fn get_session(&self, session_key: &str) -> Option<Connection>

Source

pub fn get_user_sessions(&self, user_key: &str) -> Vec<Connection>

Source

pub fn count_user_sessions(&self, user_key: &str) -> usize

Source

pub fn count_tenant_sessions(&self, tenant_id: &str) -> u64

Source

pub fn all_sessions(&self) -> Vec<(String, Connection)>

Snapshot of all active sessions.

Returns a vector of (session_key, Connection). Intended for best-effort shutdown/draining logic.

Source

pub fn len_sessions(&self) -> usize

Source

pub fn evict_oldest(&self, user_key: &str) -> Option<(String, Connection)>

Evict the oldest session for this user. Returns (victim_session_key, victim_connection).

Trait Implementations§

Source§

impl Default for SessionRegistry

Source§

fn default() -> SessionRegistry

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,