pub struct ConnectionTracker { /* private fields */ }Expand description
Connection tracker for managing active WebSocket connections
Implementations§
Source§impl ConnectionTracker
impl ConnectionTracker
pub fn new() -> Self
Sourcepub fn register(
&self,
key_info: &ApiKeyInfo,
remote_addr: SocketAddr,
) -> Result<ConnectionInfo, WsAuthError>
pub fn register( &self, key_info: &ApiKeyInfo, remote_addr: SocketAddr, ) -> Result<ConnectionInfo, WsAuthError>
Register a new connection
Sourcepub fn unregister(&self, connection_id: Uuid)
pub fn unregister(&self, connection_id: Uuid)
Unregister a connection
Sourcepub fn check_rate_limit(&self, connection_id: Uuid) -> Result<(), WsAuthError>
pub fn check_rate_limit(&self, connection_id: Uuid) -> Result<(), WsAuthError>
Check and update rate limit, returns true if allowed
Sourcepub fn get(&self, connection_id: Uuid) -> Option<ConnectionInfo>
pub fn get(&self, connection_id: Uuid) -> Option<ConnectionInfo>
Get connection info
Sourcepub fn get_by_key(&self, key_id: &str) -> Vec<ConnectionInfo>
pub fn get_by_key(&self, key_id: &str) -> Vec<ConnectionInfo>
Get all connections for an API key
Sourcepub fn total_connections(&self) -> usize
pub fn total_connections(&self) -> usize
Get total active connection count
Sourcepub fn connection_count(&self, key_id: &str) -> usize
pub fn connection_count(&self, key_id: &str) -> usize
Get connection count for a specific API key
Sourcepub fn cleanup_stale(&self, max_idle: Duration)
pub fn cleanup_stale(&self, max_idle: Duration)
Clean up expired/stale connections
Trait Implementations§
Source§impl Debug for ConnectionTracker
impl Debug for ConnectionTracker
Auto Trait Implementations§
impl !Freeze for ConnectionTracker
impl !RefUnwindSafe for ConnectionTracker
impl Send for ConnectionTracker
impl Sync for ConnectionTracker
impl Unpin for ConnectionTracker
impl UnwindSafe for ConnectionTracker
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
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>
Converts
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>
Converts
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