pub struct SessionRegistry {
pub sessions: RwLock<HashMap<String, SharedSession>>,
/* private fields */
}Fields§
§sessions: RwLock<HashMap<String, SharedSession>>Implementations§
Source§impl SessionRegistry
impl SessionRegistry
pub fn new() -> Self
pub fn with_persistence<P: AsRef<Path>>(dir: P) -> Result<Self>
Sourcepub async fn persist_snapshot(&self) -> Result<()>
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.
Clone the shared handle for a session (brief map read; no session lock).
pub async fn get_session(&self, session_id: &str) -> Option<Session>
pub async fn get_all_sessions(&self) -> Vec<Session>
Sourcepub async fn session_ids_after(
&self,
after: Option<&str>,
limit: usize,
) -> Vec<String>
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.