import { Connection, ConnectOptions } from './connection'; import { DbProvider } from './db-provider'; import { PoolExecutor } from './pool-executor'; export interface PoolOptions { max?: number; /** * 不能小于零 */ min?: number; connectTimeout?: number; idleTimeout?: number; } export declare const DefaultPoolOptions: PoolOptions; export declare class Pool { readonly connectionOptions: ConnectOptions; readonly poolOptions: Readonly>; readonly provider: DbProvider; private readonly _emitter; constructor(provider: string | DbProvider, poolOptions: PoolOptions, connectionOptions: ConnectOptions); on(event: 'healthy-changed', handler: (health: boolean) => void): this; on(event: 'acquire', handler: (conn: Connection) => void): this; on(event: 'release', handler: (conn: Connection) => void): this; on(event: 'connection-open', handler: (conn: Connection) => void): this; on(event: 'connection-close', handler: (conn: Connection) => void): this; on(event: 'log', handler: (message: string) => void): this; off(event: 'healthy-changed', handler: (health: boolean) => void): this; off(event: 'acquire', handler: (conn: Connection) => void): this; off(event: 'release', handler: (conn: Connection) => void): this; off(event: 'connection-open', handler: (conn: Connection) => void): this; off(event: 'connection-close', handler: (conn: Connection) => void): this; off(event: 'log', handler: (message: string) => void): this; private pool?; get opened(): boolean; private checkOpened; private _healthy?; /** * 当前连接池健康状态 */ get healthy(): boolean | undefined; private test; private _create; private setHealthy; open(): Promise; close(): Promise; /** * 获取连接 */ acquire(): Promise; release(conn: Connection): void; private _executor?; /** * 全局执行器,该执行器在执行SQL时会自动请求和释放连接,但不保证所有执行的SQL都在同一个数据库连接中。 */ get executor(): PoolExecutor; /** * 当前总连接数 */ get size(): number; /** * 当前可用连接数 */ get available(): number; /** * 当前等待请求数 */ get pending(): number; /** * 当前使用中连接数 */ get borrowed(): number; }