pub struct Presence { /* private fields */ }Expand description
Room presence: room_key -> sessions, session_key -> rooms.
Sprint 5: Added user-level indexing and tenant counters for governance. Lock-free best-effort design: under heavy contention, limits can be temporarily exceeded by a small margin to preserve throughput.
Implementations§
Source§impl Presence
impl Presence
pub fn new() -> Presence
Sourcepub fn try_join(
&self,
tenant_id: &str,
room_key: &str,
user_key: &str,
session_key: &str,
limits: &TenantLimits,
) -> Result<(), WsPrismError>
pub fn try_join( &self, tenant_id: &str, room_key: &str, user_key: &str, session_key: &str, limits: &TenantLimits, ) -> Result<(), WsPrismError>
Attempt to join a room with per-tenant/user/room limits enforced.
Concurrency note: This uses lock-free counters and map lookups for
performance. The check (e.g., current < limit) and the subsequent
insert are not atomic across threads, so at high contention the limit
may be exceeded by a small margin (acceptable trade-off for throughput).
Do not rely on this for exact “hard” ceilings; it is designed for fast
best-effort enforcement in a single-node gateway.
pub fn leave( &self, tenant_id: &str, room_key: &str, user_key: &str, session_key: &str, )
pub fn sessions_in(&self, room_key: &str) -> Vec<String>
pub fn cleanup_session( &self, tenant_id: &str, user_key: &str, session_key: &str, )
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Presence
impl !RefUnwindSafe for Presence
impl Send for Presence
impl Sync for Presence
impl Unpin for Presence
impl UnwindSafe for Presence
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
Mutably borrows from an owned value. Read more