pub struct ConnectionAcceptor<T, A> { /* private fields */ }Expand description
ConnectionAcceptor manages incoming connections with resource limits and lifecycle control.
This struct handles accepting new connections from the transport layer, limiting concurrent connections, and delegating each connection to a processor.
Generic parameters:
T: The acceptor type that accepts new connections from the transportA: The authenticator type that handles connection authentication
Implementations§
Source§impl<T: Acceptor, A: Authenticator<T::Connection> + 'static> ConnectionAcceptor<T, A>
impl<T: Acceptor, A: Authenticator<T::Connection> + 'static> ConnectionAcceptor<T, A>
Sourcepub fn new(acceptor: T, authenticator: A) -> Self
pub fn new(acceptor: T, authenticator: A) -> Self
Creates a new connection acceptor with the given acceptor and authenticator.
The acceptor will use default connection configuration if not provided.
Sourcepub fn with_config(
acceptor: T,
authenticator: A,
config: Arc<ConnectionConfig>,
) -> Self
pub fn with_config( acceptor: T, authenticator: A, config: Arc<ConnectionConfig>, ) -> Self
Creates a new connection acceptor with custom connection configuration.
Sourcepub fn metrics(&self) -> Metrics
pub fn metrics(&self) -> Metrics
Returns a clone-able handle to runtime metrics.
Counters are incremented as connections/streams flow through this acceptor;
callers can metrics.snapshot() at any time to read them.
Sourcepub async fn accept_loop(&self, shutdown_rx: Receiver<()>) -> Result<()>
pub async fn accept_loop(&self, shutdown_rx: Receiver<()>) -> Result<()>
Main accept loop that accepts incoming connections and manages them with resource limits.
This method will:
- Accept new connections from the acceptor
- Acquire a semaphore permit to limit total concurrent connections
- Spawn a task to handle each connection
- Gracefully handle shutdown signals