pub struct ConnectionTracker { /* private fields */ }Expand description
Tracker for managing active connections.
Provides connection counting, per-IP limits, and connection metadata.
Implementations§
Source§impl ConnectionTracker
impl ConnectionTracker
Sourcepub fn new(limits: ConnectionLimits) -> Self
pub fn new(limits: ConnectionLimits) -> Self
Create a new connection tracker with the given limits.
Sourcepub fn limits(&self) -> &ConnectionLimits
pub fn limits(&self) -> &ConnectionLimits
Get the connection limits.
Sourcepub fn active_connections(&self) -> u64
pub fn active_connections(&self) -> u64
Get the current number of active connections.
Sourcepub fn connections_for_ip(&self, ip: IpAddr) -> u64
pub fn connections_for_ip(&self, ip: IpAddr) -> u64
Get connections for a specific IP.
Sourcepub fn try_acquire(
&self,
remote_addr: Option<SocketAddr>,
) -> Option<ConnectionGuard>
pub fn try_acquire( &self, remote_addr: Option<SocketAddr>, ) -> Option<ConnectionGuard>
Try to acquire a connection slot.
Returns None if connection limits are exceeded.
Sourcepub fn list_connections(&self) -> Vec<ConnectionInfo>
pub fn list_connections(&self) -> Vec<ConnectionInfo>
Get information about all active connections.
Sourcepub fn get_connection(&self, id: u64) -> Option<ConnectionInfo>
pub fn get_connection(&self, id: u64) -> Option<ConnectionInfo>
Get information about a specific connection.
Trait Implementations§
Source§impl Clone for ConnectionTracker
impl Clone for ConnectionTracker
Source§impl Debug for ConnectionTracker
impl Debug for ConnectionTracker
Auto Trait Implementations§
impl !RefUnwindSafe for ConnectionTracker
impl !UnwindSafe for ConnectionTracker
impl Freeze for ConnectionTracker
impl Send for ConnectionTracker
impl Sync for ConnectionTracker
impl Unpin for ConnectionTracker
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request