Skip to main content

SessionRegistry

Struct SessionRegistry 

Source
pub struct SessionRegistry {
    pub sessions: RwLock<HashMap<String, SharedSession>>,
    /* private fields */
}

Fields§

§sessions: RwLock<HashMap<String, SharedSession>>

Implementations§

Source§

impl SessionRegistry

Source

pub fn new() -> Self

Source

pub fn with_persistence<P: AsRef<Path>>(dir: P) -> Result<Self>

Source

pub async fn persist_snapshot(&self) -> Result<()>

Snapshot every session (locking each briefly) and persist. Never holds the map lock across the per-session locks or the fs write.

Source

pub async fn get_shared(&self, session_id: &str) -> Option<SharedSession>

Clone the shared handle for a session (brief map read; no session lock).

Source

pub async fn get_session(&self, session_id: &str) -> Option<Session>

Source

pub async fn get_all_sessions(&self) -> Vec<Session>

Source

pub async fn session_ids_after( &self, after: Option<&str>, limit: usize, ) -> Vec<String>

Session IDs strictly greater than after, ascending (byte order), at most limit. Keyset cursor primitive for ListSessions paging (see plan D1/D2).

Holds only the map read lock, for one synchronous pass — no session mutex is taken and no .await happens under the guard, per the lock-ordering contract documented above (map lock BEFORE session mutex; never hold the map lock across an await).

Each call is individually consistent, but a multi-page traversal is not a snapshot: the lock is released between pages, so concurrent mutation is visible mid-traversal. A session inserted at a key at or below the cursor is missed by the remainder of the traversal; one inserted above the cursor appears in a later page; one removed above the cursor is never emitted. Already-emitted IDs are stable — the cursor only moves forward — so no ID is ever returned twice. This is inherent to keyset paging; callers must not present a completed traversal as a point-in-time view of the registry.

limit is caller-supplied and may be arbitrarily large (usize::MAX reads as “no limit”); allocation is bounded by the map, never by the limit.

Source

pub async fn insert_recovered_session( &self, session_id: String, session: Session, )

Source

pub async fn count_open_sessions_for_initiator(&self, sender: &str) -> usize

Trait Implementations§

Source§

impl Default for SessionRegistry

Source§

fn default() -> Self

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.

Source§

impl<T> Instrument for T

Source§

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

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

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 = !

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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