1 | import { EventEmitter } from 'events';
|
2 | import { PoolConnection } from './PoolConnection.js';
|
3 | import { PoolOptions } from './Pool.js';
|
4 | import { ExecutableBase as ExecutableBaseClass } from './protocol/sequences/ExecutableBase.js';
|
5 | import { QueryableBase as QueryableBaseClass } from './protocol/sequences/QueryableBase.js';
|
6 |
|
7 |
|
8 | declare class QueryableAndExecutableBase extends QueryableBaseClass(
|
9 | ExecutableBaseClass(EventEmitter),
|
10 | ) {}
|
11 |
|
12 | export interface PoolClusterOptions {
|
13 | |
14 |
|
15 |
|
16 | canRetry?: boolean;
|
17 |
|
18 | |
19 |
|
20 |
|
21 |
|
22 | removeNodeErrorCount?: number;
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 | restoreNodeTimeout?: number;
|
29 |
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | defaultSelector?: string;
|
37 | }
|
38 |
|
39 | export interface PoolNamespace extends QueryableAndExecutableBase {
|
40 | getConnection(
|
41 | callback: (
|
42 | err: NodeJS.ErrnoException | null,
|
43 | connection: PoolConnection,
|
44 | ) => any,
|
45 | ): void;
|
46 | }
|
47 |
|
48 | declare class PoolCluster extends EventEmitter {
|
49 | config: PoolClusterOptions;
|
50 |
|
51 | add(config: PoolOptions): void;
|
52 | add(group: string, connectionUri: string): void;
|
53 | add(group: string, config: PoolOptions): void;
|
54 |
|
55 | end(): void;
|
56 |
|
57 | getConnection(
|
58 | callback: (
|
59 | err: NodeJS.ErrnoException | null,
|
60 | connection: PoolConnection,
|
61 | ) => void,
|
62 | ): void;
|
63 | getConnection(
|
64 | group: string,
|
65 | callback: (
|
66 | err: NodeJS.ErrnoException | null,
|
67 | connection: PoolConnection,
|
68 | ) => void,
|
69 | ): void;
|
70 | getConnection(
|
71 | group: string,
|
72 | selector: string,
|
73 | callback: (
|
74 | err: NodeJS.ErrnoException | null,
|
75 | connection: PoolConnection,
|
76 | ) => void,
|
77 | ): void;
|
78 |
|
79 | of(pattern: string, selector?: string): PoolNamespace;
|
80 |
|
81 | on(event: string, listener: (...args: any[]) => void): this;
|
82 | on(event: 'remove', listener: (nodeId: number) => void): this;
|
83 | on(event: 'warn', listener: (err: Error) => void): this;
|
84 | }
|
85 |
|
86 | export { PoolCluster };
|