-
-
Notifications
You must be signed in to change notification settings - Fork 629
/
Copy pathPoolCluster.d.ts
86 lines (73 loc) · 2.44 KB
/
PoolCluster.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
80
81
82
83
84
85
86
import { EventEmitter } from 'events';
import { PoolConnection } from './PoolConnection.js';
import { PoolOptions } from './Pool.js';
import { ExecutableBase as ExecutableBaseClass } from './protocol/sequences/ExecutableBase.js';
import { QueryableBase as QueryableBaseClass } from './protocol/sequences/QueryableBase.js';
// Expose class interfaces
declare class QueryableAndExecutableBase extends QueryableBaseClass(
ExecutableBaseClass(EventEmitter)
) {}
export interface PoolClusterOptions {
/**
* If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)
*/
canRetry?: boolean;
/**
* If connection fails, node's errorCount increases. When errorCount is greater than removeNodeErrorCount,
* remove a node in the PoolCluster. (Default: 5)
*/
removeNodeErrorCount?: number;
/**
* If connection fails, specifies the number of milliseconds before another connection attempt will be made.
* If set to 0, then node will be removed instead and never re-used. (Default: 0)
*/
restoreNodeTimeout?: number;
/**
* The default selector. (Default: RR)
* RR: Select one alternately. (Round-Robin)
* RANDOM: Select the node by random function.
* ORDER: Select the first node available unconditionally.
*/
defaultSelector?: string;
}
export interface PoolNamespace extends QueryableAndExecutableBase {
getConnection(
callback: (
err: NodeJS.ErrnoException | null,
connection: PoolConnection
) => any
): void;
}
declare class PoolCluster extends EventEmitter {
config: PoolClusterOptions;
add(config: PoolOptions): void;
add(group: string, connectionUri: string): void;
add(group: string, config: PoolOptions): void;
end(): void;
getConnection(
callback: (
err: NodeJS.ErrnoException | null,
connection: PoolConnection
) => void
): void;
getConnection(
group: string,
callback: (
err: NodeJS.ErrnoException | null,
connection: PoolConnection
) => void
): void;
getConnection(
group: string,
selector: string,
callback: (
err: NodeJS.ErrnoException | null,
connection: PoolConnection
) => void
): void;
of(pattern: string, selector?: string): PoolNamespace;
on(event: string, listener: (args: any[]) => void): this;
on(event: 'remove', listener: (nodeId: number) => void): this;
on(event: 'connection', listener: (connection: PoolConnection) => void): this;
}
export { PoolCluster };