pub struct ConnectionPool<Connector: ClientConnector> { /* private fields */ }Expand description
A connection pool for protosocket rpc clients.
Protosocket-rpc connections are shared and multiplexed, so this vends cloned handles.
You can hold onto a handle from the pool for as long as you want. There is a small
synchronization cost to getting a handle from a pool, so caching is a good idea - but
if you want to load balance a lot, you can just make a pool with as many “slots” as you
want to dilute any contention on connection state locks. The locks are typically held for
the time it takes to clone an Arc, so it’s usually nanosecond-scale synchronization,
per connection. So if you have several connections, you’ll rarely contend.
Implementations§
Source§impl<Connector: ClientConnector> ConnectionPool<Connector>
impl<Connector: ClientConnector> ConnectionPool<Connector>
Sourcepub fn new(connector: Connector, connection_count: usize) -> Self
pub fn new(connector: Connector, connection_count: usize) -> Self
Create a new connection pool.
It will try to maintain connection_count healthy connections.
Trait Implementations§
Auto Trait Implementations§
impl<Connector> Freeze for ConnectionPool<Connector>where
Connector: Freeze,
impl<Connector> RefUnwindSafe for ConnectionPool<Connector>where
Connector: RefUnwindSafe,
impl<Connector> Send for ConnectionPool<Connector>where
Connector: Send,
impl<Connector> Sync for ConnectionPool<Connector>where
Connector: Sync,
impl<Connector> Unpin for ConnectionPool<Connector>where
Connector: Unpin,
impl<Connector> UnwindSafe for ConnectionPool<Connector>where
Connector: UnwindSafe,
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