pub struct ConnectionCache<R, S, T> {
map: RwLock<IndexMap<SocketAddr, R>>,
connection_manager: S,
stats: Arc<ConnectionCacheStats>,
last_stats: AtomicInterval,
connection_pool_size: usize,
connection_config: T,
}
Fields§
§map: RwLock<IndexMap<SocketAddr, R>>
§connection_manager: S
§stats: Arc<ConnectionCacheStats>
§last_stats: AtomicInterval
§connection_pool_size: usize
§connection_config: T
Implementations§
source§impl<P, M, C> ConnectionCache<P, M, C>where
P: ConnectionPool<NewConnectionConfig = C>,
M: ConnectionManager<ConnectionPool = P, NewConnectionConfig = C>,
C: NewConnectionConfig,
impl<P, M, C> ConnectionCache<P, M, C>where P: ConnectionPool<NewConnectionConfig = C>, M: ConnectionManager<ConnectionPool = P, NewConnectionConfig = C>, C: NewConnectionConfig,
pub fn new( connection_manager: M, connection_pool_size: usize ) -> Result<Self, ClientError>
pub fn new_with_config( connection_pool_size: usize, connection_config: C, connection_manager: M ) -> Self
sourcefn create_connection(
&self,
lock_timing_ms: &mut u64,
addr: &SocketAddr
) -> CreateConnectionResult<<P as ConnectionPool>::BaseClientConnection>
fn create_connection( &self, lock_timing_ms: &mut u64, addr: &SocketAddr ) -> CreateConnectionResult<<P as ConnectionPool>::BaseClientConnection>
Create a lazy connection object under the exclusive lock of the cache map if there is not enough used connections in the connection pool for the specified address. Returns CreateConnectionResult.
fn get_or_add_connection( &self, addr: &SocketAddr ) -> GetConnectionResult<<P as ConnectionPool>::BaseClientConnection>
fn get_connection_and_log_stats( &self, addr: &SocketAddr ) -> (Arc<<P as ConnectionPool>::BaseClientConnection>, Arc<ConnectionCacheStats>)
pub fn get_connection( &self, addr: &SocketAddr ) -> Arc<<<P as ConnectionPool>::BaseClientConnection as BaseClientConnection>::BlockingClientConnection>
pub fn get_nonblocking_connection( &self, addr: &SocketAddr ) -> Arc<<<P as ConnectionPool>::BaseClientConnection as BaseClientConnection>::NonblockingClientConnection>
Auto Trait Implementations§
impl<R, S, T> RefUnwindSafe for ConnectionCache<R, S, T>where S: RefUnwindSafe, T: RefUnwindSafe,
impl<R, S, T> Send for ConnectionCache<R, S, T>where R: Send, S: Send, T: Send,
impl<R, S, T> Sync for ConnectionCache<R, S, T>where R: Send + Sync, S: Sync, T: Sync,
impl<R, S, T> Unpin for ConnectionCache<R, S, T>where R: Unpin, S: Unpin, T: Unpin,
impl<R, S, T> UnwindSafe for ConnectionCache<R, S, T>where S: UnwindSafe, T: 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