UNPKG

inceptum

Version:

hipages take on the foundational library for enterprise-grade apps written in NodeJS

71 lines (70 loc) 2.48 kB
import { Gauge, Counter, Histogram } from 'prom-client'; import { ExtendedGaugeInternal } from 'prometheus-extended-gauge'; import { Pool, Factory } from 'generic-pool'; /** * Sensible defaults for the connection pool options */ export declare const DEFAULT_CONNECTION_POOL_OPTIONS: PoolConfig<any>; /** * Base interface for the configuration information needed to create a new connection */ export interface ConnectionConfig { user: string; } /** * Class for the config of a Pool. * This class is not supposed to be extended, as the framework does not expose methods to override the creation of the * connection pools. */ export interface PoolConfig<C extends ConnectionConfig> { max?: number; min?: number; maxWaitingClients?: number; testOnBorrow?: boolean; acquireTimeoutMillis?: number; evictionRunIntervalMillis?: number; numTestsPerRun?: number; softIdleTimeoutMillis?: number; idleTimeoutMillis?: number; connectionConfig?: C; } export declare abstract class ConnectionPool<T> { abstract getName(): string; abstract isReadonly(): boolean; abstract getConnection(): Promise<T>; abstract release(connection: T): any; abstract start(): Promise<void>; abstract stop(): Promise<void>; } export declare class InstrumentedFactory<T> implements Factory<T> { validateFailedCounter: Counter.Internal; connectErrorsCounter: Counter.Internal; connectTimeHistogram: Histogram.Internal; totalGauge: Gauge.Internal; factory: Factory<T>; constructor(factory: Factory<T>, name: string, readonly: boolean); create(): Promise<T>; destroy(client: T): Promise<void>; validate(client: T): Promise<boolean>; } export declare class InstrumentedConnectionPool<C, CC extends ConnectionConfig> extends ConnectionPool<C> { readonly: boolean; name: string; activeGauge: ExtendedGaugeInternal; useTimeHistogram: Histogram.Internal; acquireErrorsCounter: Counter.Internal; pool: Pool<C>; acquireTimeHistogram: Histogram.Internal; options: PoolConfig<CC>; private status; maxConnectionLimitGauge: Gauge.Internal; constructor(factory: Factory<C>, options: PoolConfig<CC>, name: string, readonly: boolean); getName(): string; isReadonly(): boolean; getConnection(): Promise<C>; private getGenericPoolOptions; release(connection: C): void; start(): Promise<void>; stop(): Promise<void>; getOptions(): PoolConfig<CC>; }