pub struct ConnectionManager { /* private fields */ }Expand description
Manages connection limits, request queuing, and shutdown coordination.
Implementations§
Source§impl ConnectionManager
impl ConnectionManager
Sourcepub fn new(config: ConnectionConfig) -> Self
pub fn new(config: ConnectionConfig) -> Self
Create a new connection manager with the given configuration.
Sourcepub fn try_accept(&self) -> Option<ConnectionGuard>
pub fn try_accept(&self) -> Option<ConnectionGuard>
Try to accept a new connection. Returns a guard that releases the slot on drop. Returns None if the connection limit is reached or server is shutting down.
Sourcepub async fn acquire_request_permit(&self) -> Option<OwnedSemaphorePermit>
pub async fn acquire_request_permit(&self) -> Option<OwnedSemaphorePermit>
Get a permit for processing a request. Blocks if at capacity. Returns None if the request times out waiting for a slot.
Sourcepub fn idle_timeout(&self) -> Duration
pub fn idle_timeout(&self) -> Duration
Get the idle timeout duration.
Sourcepub fn request_timeout(&self) -> Duration
pub fn request_timeout(&self) -> Duration
Get the request timeout duration.
Sourcepub fn is_shutting_down(&self) -> bool
pub fn is_shutting_down(&self) -> bool
Check if the server is shutting down.
Sourcepub fn initiate_shutdown(&self)
pub fn initiate_shutdown(&self)
Initiate graceful shutdown.
Sourcepub fn active_connections(&self) -> u64
pub fn active_connections(&self) -> u64
Get current active connection count.
Sourcepub fn rejected_connections(&self) -> u64
pub fn rejected_connections(&self) -> u64
Get total rejected connections.
Sourcepub fn drain_timeout(&self) -> Duration
pub fn drain_timeout(&self) -> Duration
Get the drain timeout for graceful shutdown.
Sourcepub async fn wait_for_drain(&self)
pub async fn wait_for_drain(&self)
Wait until all connections are closed or drain timeout expires.
Auto Trait Implementations§
impl !Freeze for ConnectionManager
impl !RefUnwindSafe for ConnectionManager
impl !UnwindSafe for ConnectionManager
impl Send for ConnectionManager
impl Sync for ConnectionManager
impl Unpin for ConnectionManager
impl UnsafeUnpin for ConnectionManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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