Skip to main content

ConnectionPool

Trait ConnectionPool 

Source
pub trait ConnectionPool: Send + Sync {
    // Required methods
    fn get_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        role: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = DbResult<Session>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn status(&self) -> PoolStatus;
    fn config(&self) -> &DbConfig;
}
Expand description

连接池抽象 trait

定义连接池的通用接口,便于测试和替换实现

Required Methods§

Source

fn get_session<'life0, 'life1, 'async_trait>( &'life0 self, role: &'life1 str, ) -> Pin<Box<dyn Future<Output = DbResult<Session>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

获取会话

§Arguments
  • role - 用户角色
§Returns

返回数据库会话

Source

fn status(&self) -> PoolStatus

获取连接池状态

§Returns

返回连接池状态信息

Source

fn config(&self) -> &DbConfig

获取配置

§Returns

返回连接池配置

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§