Skip to content

Commit

Permalink
fix: add ready function to index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Teow Hua Jun authored and Teow Hua Jun committed Jul 1, 2022
1 parent 9b7c65b commit 0a5ef1d
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,45 @@
import { EventEmitter } from "events";

export class Pool<T> extends EventEmitter {
spareResourceCapacity: number;
size: number;
available: number;
borrowed: number;
pending: number;
max: number;
min: number;
spareResourceCapacity: number;
size: number;
available: number;
borrowed: number;
pending: number;
max: number;
min: number;

start(): void;
acquire(priority?: number): Promise<T>;
release(resource: T): Promise<void>;
destroy(resource: T): Promise<void>;
drain(): Promise<void>;
clear(): Promise<void>;
use<U>(cb: (resource: T) => U | Promise<U>): Promise<U>;
isBorrowedResource(resource: T): boolean;
start(): void;
acquire(priority?: number): Promise<T>;
release(resource: T): Promise<void>;
destroy(resource: T): Promise<void>;
drain(): Promise<void>;
clear(): Promise<void>;
use<U>(cb: (resource: T) => U | Promise<U>): Promise<U>;
isBorrowedResource(resource: T): boolean;
ready(): Promise<void>;
}

export interface Factory<T> {
create(): Promise<T>;
destroy(client: T): Promise<void>;
validate?(client: T): Promise<boolean>;
create(): Promise<T>;
destroy(client: T): Promise<void>;
validate?(client: T): Promise<boolean>;
}

export interface Options {
max?: number;
min?: number;
maxWaitingClients?: number;
testOnBorrow?: boolean;
testOnReturn?: boolean;
acquireTimeoutMillis?: number;
fifo?: boolean;
priorityRange?: number;
autostart?: boolean;
evictionRunIntervalMillis?: number;
numTestsPerEvictionRun?: number;
softIdleTimeoutMillis?: number;
idleTimeoutMillis?: number;
max?: number;
min?: number;
maxWaitingClients?: number;
testOnBorrow?: boolean;
testOnReturn?: boolean;
acquireTimeoutMillis?: number;
fifo?: boolean;
priorityRange?: number;
autostart?: boolean;
evictionRunIntervalMillis?: number;
numTestsPerEvictionRun?: number;
softIdleTimeoutMillis?: number;
idleTimeoutMillis?: number;
}

export function createPool<T>(factory: Factory<T>, opts?: Options): Pool<T>;

0 comments on commit 0a5ef1d

Please sign in to comment.