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 { ... }
}๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Required Associated Typesยง
type NewConnectionConfig: NewConnectionConfig
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.type BaseClientConnection: BaseClientConnection
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Required Methodsยง
Sourcefn add_connection(
&mut self,
config: &Self::NewConnectionConfig,
addr: &SocketAddr,
) -> usize
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
fn add_connection( &mut self, config: &Self::NewConnectionConfig, addr: &SocketAddr, ) -> usize
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Add a connection to the pool and return its index
Sourcefn num_connections(&self) -> usize
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
fn num_connections(&self) -> usize
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Get the number of current connections in the pool
Sourcefn get(
&self,
index: usize,
) -> Result<Arc<Self::BaseClientConnection>, ConnectionPoolError>
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
fn get( &self, index: usize, ) -> Result<Arc<Self::BaseClientConnection>, ConnectionPoolError>
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Get a connection based on its index in the pool, without checking if the
fn create_pool_entry( &self, config: &Self::NewConnectionConfig, addr: &SocketAddr, ) -> Arc<Self::BaseClientConnection>
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Provided Methodsยง
Sourcefn borrow_connection(&self) -> Arc<Self::BaseClientConnection>
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
fn borrow_connection(&self) -> Arc<Self::BaseClientConnection>
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.Get a connection from the pool. It must have at least one connection in the pool. This randomly picks a connection in the pool.
Sourcefn check_pool_status(&self, required_pool_size: usize) -> PoolStatus
๐Deprecated since 3.1.0: This crate has been marked for formal inclusion in the Agave Unstable API. From v4.0.0 onward, the agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.
fn check_pool_status(&self, required_pool_size: usize) -> PoolStatus
agave-unstable-api crate feature must be specified to acknowledge use of an interface that may break without warning.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.