pub struct Pool { /* private fields */ }Expand description
A pool of stream connections.
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new(config: PoolConfig, limits: Limits, events: Sender<Event>) -> Self
pub fn new(config: PoolConfig, limits: Limits, events: Sender<Event>) -> Self
A pool that reports what it receives to events.
Sourcepub fn accept(&mut self, stream: TcpStream, peer: SocketAddr)
pub fn accept(&mut self, stream: TcpStream, peer: SocketAddr)
Adopt a connection a peer opened.
Sourcepub async fn send(&mut self, key: &ConnectionKey, bytes: Bytes) -> Result<()>
pub async fn send(&mut self, key: &ConnectionKey, bytes: Bytes) -> Result<()>
Send to a peer, connecting if there is no usable connection.
The dial never blocks the caller. A peer that black-holes SYN takes the OS connect timeout to fail — around two minutes — and the endpoint loop that calls this also owns every transaction timer. Waiting here would stop retransmissions for calls that have nothing to do with this peer, so the connection is established inside its own task and the bytes wait in the channel until it is up.
Sourcepub fn accept_tls(&mut self, stream: TlsStream<TcpStream>, peer: SocketAddr)
pub fn accept_tls(&mut self, stream: TlsStream<TcpStream>, peer: SocketAddr)
Adopt a TLS connection a peer opened, once the handshake has completed.
Sourcepub fn accept_quic(&mut self, connection: Connection, peer: SocketAddr)
pub fn accept_quic(&mut self, connection: Connection, peer: SocketAddr)
Adopt an authenticated QUIC connection opened by a peer.
Sourcepub async fn send_tls(
&mut self,
key: &ConnectionKey,
verification_name: &str,
client: &ClientTls,
bytes: Bytes,
) -> Result<()>
pub async fn send_tls( &mut self, key: &ConnectionKey, verification_name: &str, client: &ClientTls, bytes: Bytes, ) -> Result<()>
Send to a peer over TLS, connecting and verifying if there is no usable connection.
The verification name is the host from the URI, not the address — see
docs/specs/sip-tls.md §3.3 — and it is part of the pool key, so a connection verified
as one name is never handed to traffic for another.
Sourcepub fn accept_ws<S>(
&mut self,
ws: Socket<S>,
key: ConnectionKey,
keepalive: Duration,
)
pub fn accept_ws<S>( &mut self, ws: Socket<S>, key: ConnectionKey, keepalive: Duration, )
Adopt a WebSocket connection a peer opened, once the handshake has completed.
Sourcepub async fn send_ws(
&mut self,
key: &ConnectionKey,
authority: &str,
keepalive: Duration,
client: Option<&ClientTls>,
bytes: Bytes,
) -> Result<()>
pub async fn send_ws( &mut self, key: &ConnectionKey, authority: &str, keepalive: Duration, client: Option<&ClientTls>, bytes: Bytes, ) -> Result<()>
Send to a peer over WebSocket, doing the handshake if there is no usable connection.
authority is what goes in the Host header of the upgrade request and, under WSS, the
name the certificate must be valid for. Both are the host from the URI.
Sourcepub fn remove(&mut self, key: &ConnectionKey, id: u64) -> bool
pub fn remove(&mut self, key: &ConnectionKey, id: u64) -> bool
Forget a connection that has closed.
Sourcepub fn holds(&self, key: &ConnectionKey) -> bool
pub fn holds(&self, key: &ConnectionKey) -> bool
Whether this connection is held.
Sourcepub async fn send_on_existing(
&mut self,
key: &ConnectionKey,
bytes: Bytes,
) -> bool
pub async fn send_on_existing( &mut self, key: &ConnectionKey, bytes: Bytes, ) -> bool
Answer on the connection a request arrived over, if it is still open.
Always tried before anything the Via says: opening a new connection to a NAT-ed
client’s advertised address cannot work, which is what RFC 5923 exists to say.
Sourcepub fn evict_idle(&mut self) -> Vec<ConnectionKey>
pub fn evict_idle(&mut self) -> Vec<ConnectionKey>
Close connections idle for longer than the configured timeout.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
impl !RefUnwindSafe for Pool
impl Send for Pool
impl !Sync for Pool
impl Unpin for Pool
impl UnsafeUnpin for Pool
impl !UnwindSafe for Pool
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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