-
-
Notifications
You must be signed in to change notification settings - Fork 636
/
Copy pathPool.d.ts
79 lines (64 loc) · 2.47 KB
/
Pool.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { EventEmitter } from 'events';
import { PrepareStatementInfo } from './protocol/sequences/Prepare.js';
import { ConnectionOptions } from './Connection.js';
import { PoolConnection } from './PoolConnection.js';
import {
Pool as PromisePool,
PoolConnection as PromisePoolConnection,
} from '../../../promise.js';
import { QueryableBase } from './protocol/sequences/QueryableBase.js';
import { ExecutableBase } from './protocol/sequences/ExecutableBase.js';
export interface PoolOptions extends ConnectionOptions {
/**
* Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue
* the connection request and call it when one becomes available. If false, the pool will immediately call back with an error.
* (Default: true)
*/
waitForConnections?: boolean;
/**
* The maximum number of connections to create at once. (Default: 10)
*/
connectionLimit?: number;
/**
* The maximum number of idle connections. (Default: same as `connectionLimit`)
*/
maxIdle?: number;
/**
* The idle connections timeout, in milliseconds. (Default: 60000)
*/
idleTimeout?: number;
/**
* The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there
* is no limit to the number of queued connection requests. (Default: 0)
*/
queueLimit?: number;
/**
* Enable keep-alive on the socket. (Default: true)
*/
enableKeepAlive?: boolean;
/**
* If keep-alive is enabled users can supply an initial delay. (Default: 0)
*/
keepAliveInitialDelay?: number;
}
declare class Pool extends QueryableBase(ExecutableBase(EventEmitter)) {
getConnection(
callback: (
err: NodeJS.ErrnoException | null,
connection: PoolConnection
) => any
): void;
releaseConnection(connection: PoolConnection | PromisePoolConnection): void;
end(
callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any
): void;
on(event: string, listener: (...args: any[]) => void): this;
on(event: 'connection', listener: (connection: PoolConnection) => any): this;
on(event: 'acquire', listener: (connection: PoolConnection) => any): this;
on(event: 'release', listener: (connection: PoolConnection) => any): this;
on(event: 'enqueue', listener: () => any): this;
unprepare(sql: string): PrepareStatementInfo;
promise(promiseImpl?: PromiseConstructor): PromisePool;
config: PoolOptions;
}
export { Pool };