import { EventEmitter } from 'events'; import { PoolState } from './constants.js'; import { PoolOptions } from './pool-options.js'; import type { Callback, PoolConfiguration, PoolFactory } from './types.js'; export declare class Pool extends EventEmitter { private readonly _options; private readonly _factory; private _allResources; private _requestQueue; private _acquiredResources; private _idleResources; private _creating; private _requestsProcessing; private _state; private _houseKeepTimer; private _closeWaitTimer; constructor(factory: PoolFactory, config?: PoolConfiguration); /** * Returns Pool options */ get options(): PoolOptions; /** * Returns number of resources that are currently acquired */ get acquired(): number; /** * Returns number of unused resources in the pool */ get available(): number; /** * Returns number of resources currently creating */ get creating(): number; /** * Returns number of callers waiting to acquire a resource */ get pending(): number; /** * Returns number of resources in the pool * regardless of whether they are idle or in use */ get size(): number; /** * Returns state of the pool */ get state(): PoolState; /** * Starts the pool and begins creating of resources, starts the housekeeper and any other internal logic. * Note: This method is not needed to be called. Pool instance will automatically be started when acquire() method is called */ start(): void; /** * Shuts down the pool and destroys all resources. */ close(): void; close(callback?: Callback): void; close(terminateWait?: number, callback?: Callback): void; close(force?: boolean, callback?: Callback): void; closeAsync(): Promise; closeAsync(terminateWait?: number): Promise; closeAsync(force?: boolean): Promise; /** * Acquires `resource` from the pool or create a new one */ acquire(): Promise; acquire(callback: Callback): void; /** * Releases an allocated `resource` and let it back to pool. */ release(resource: T, callback?: Callback): void; /** * Async version of release(). */ releaseAsync(resource: T): Promise; /** * Releases, destroys and removes any `resource` from `Pool`. */ destroy(resource: T, callback?: Callback): any; /** * Async version of destroy(). */ destroyAsync(resource: T): Promise; /** * Returns if a `resource` has been acquired from the pool and not yet released or destroyed. */ isAcquired(resource: T): boolean; /** * Returns if the pool contains a `resource` */ includes(resource: T): boolean; private _processNextRequest; emit(event: string | symbol, ...args: any[]): boolean; /** * Creates new resource */ private _createResource; private _setHouseKeep; private _houseKeep; private _ensureMin; private _itemSetAcquired; private _itemDetach; private _itemSetIdle; private _itemDestroy; private _itemValidate; }