unmbt/ciallo-data/pool does not have a README file

    Lease

    pub struct Lease[Conn] {
    // private fields
    }

    连接池租约(协程取消或事务 ROLLBACK 失败时调用 mark_tainted 立即驱逐销毁脏连接)

    Lease::conn

    fn[Conn] Lease::conn(self : Lease[Conn]) -> Conn

    Lease::is_tainted

    fn[Conn] Lease::is_tainted(self : Lease[Conn]) -> Bool

    Lease::mark_tainted

    fn[Conn] Lease::mark_tainted(self : Lease[Conn]) -> Unit

    Pool

    pub struct Pool[Conn] {
    // private fields
    }

    协作式无锁连接池(同步 while + @async.Cond::wait 防边缘信号丢失;defer + protect_from_cancel 保底归还/销毁)

    Pool::Pool

    fn[Conn] Pool::Pool(config? : PoolConfig, connect~ : async () -> Conn raise
    DataError
    , health_check? : async (Conn) -> Bool, close~ : async (Conn) -> Unit) -> Pool[Conn]

    Pool::close

    async fn[Conn] Pool::close(self : Pool[Conn]) -> Unit

    关闭连接池:标记关闭、释放全部空闲连接并唤醒所有等待协程

    Pool::stats

    fn[Conn] Pool::stats(self : Pool[Conn]) -> PoolStats

    Pool::with_conn

    async fn[Conn, R] Pool::with_conn(self : Pool[Conn], task : async (Lease[Conn]) -> R) -> R

    从池中获取租约执行任务;若主动 mark_tainted 或协程被取消,经 protect_from_cancel 销毁脏连接

    PoolConfig

    pub(all) struct PoolConfig {
    max_connections : Int
    min_idle : Int
    acquire_timeout_ms : Int
    idle_timeout_ms : Int64
    max_lifetime_ms : Int64
    } derive(Eq,
    Debug
    )

    异步连接池配置(对齐 ADR-012:连接数与获取超时毫秒使用 Int32,空转与生命周期毫秒使用 Int64)

    PoolConfig::PoolConfig

    fn PoolConfig::PoolConfig(max_connections? : Int, min_idle? : Int, acquire_timeout_ms? : Int, idle_timeout_ms? : Int64, max_lifetime_ms? : Int64) -> PoolConfig

    PoolStats

    pub(all) struct PoolStats {
    total : Int
    idle : Int
    in_use : Int
    closed : Bool
    } derive(Eq,
    Debug
    )

    Source Files