solana_connection_cache::connection_cache

Trait ConnectionPool

Source
pub trait ConnectionPool:
    Send
    + Sync
    + 'static {
    type NewConnectionConfig: NewConnectionConfig;
    type BaseClientConnection: BaseClientConnection;

    // Required methods
    fn add_connection(
        &mut self,
        config: &Self::NewConnectionConfig,
        addr: &SocketAddr,
    ) -> usize;
    fn num_connections(&self) -> usize;
    fn get(
        &self,
        index: usize,
    ) -> Result<Arc<Self::BaseClientConnection>, ConnectionPoolError>;
    fn create_pool_entry(
        &self,
        config: &Self::NewConnectionConfig,
        addr: &SocketAddr,
    ) -> Arc<Self::BaseClientConnection>;

    // Provided methods
    fn borrow_connection(&self) -> Arc<Self::BaseClientConnection> { ... }
    fn check_pool_status(&self, required_pool_size: usize) -> PoolStatus { ... }
}

Required Associated Types§

Required Methods§

Source

fn add_connection( &mut self, config: &Self::NewConnectionConfig, addr: &SocketAddr, ) -> usize

Add a connection to the pool and return its index

Source

fn num_connections(&self) -> usize

Get the number of current connections in the pool

Source

fn get( &self, index: usize, ) -> Result<Arc<Self::BaseClientConnection>, ConnectionPoolError>

Get a connection based on its index in the pool, without checking if the

Source

fn create_pool_entry( &self, config: &Self::NewConnectionConfig, addr: &SocketAddr, ) -> Arc<Self::BaseClientConnection>

Provided Methods§

Source

fn borrow_connection(&self) -> Arc<Self::BaseClientConnection>

Get a connection from the pool. It must have at least one connection in the pool. This randomly picks a connection in the pool.

Source

fn check_pool_status(&self, required_pool_size: usize) -> PoolStatus

Check if we need to create a new connection. If the count of the connections is smaller than the pool size and if there is no connection at all.

Implementors§