Skip to content

Commit 7f38496

Browse files
committed
fix: create promise-based PoolCluster typings
1 parent 3902ca6 commit 7f38496

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

promise.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
QueryOptions,
99
ConnectionOptions,
1010
PoolOptions,
11+
PoolClusterOptions,
1112
Pool as CorePool,
1213
} from './index.js';
1314
import { ExecutableBase as ExecutableBaseClass } from './typings/mysql/lib/protocol/sequences/promise/ExecutableBase.js';
@@ -95,10 +96,36 @@ export interface Pool extends Connection {
9596
pool: CorePool;
9697
}
9798

99+
export interface PoolNamespace extends QueryableAndExecutableBase {
100+
getConnection(): Promise<PoolConnection>;
101+
}
102+
103+
export interface PoolCluster extends EventEmitter {
104+
config: PoolClusterOptions;
105+
106+
add(config: PoolOptions): void;
107+
add(group: string, connectionUri: string): void;
108+
add(group: string, config: PoolOptions): void;
109+
110+
end(): Promise<void>;
111+
112+
getConnection(): Promise<PoolConnection>;
113+
getConnection(group: string): Promise<PoolConnection>;
114+
getConnection(group: string, selector: string): Promise<PoolConnection>;
115+
116+
of(pattern: string, selector?: string): PoolNamespace;
117+
118+
on(event: string, listener: (args: any[]) => void): this;
119+
on(event: 'remove', listener: (nodeId: number) => void): this;
120+
on(event: 'connection', listener: (connection: PoolConnection) => void): this;
121+
}
122+
98123
export function createConnection(connectionUri: string): Promise<Connection>;
99124
export function createConnection(
100125
config: ConnectionOptions
101126
): Promise<Connection>;
102127

103128
export function createPool(connectionUri: string): Pool;
104129
export function createPool(config: PoolOptions): Pool;
130+
131+
export function createPoolCluster(config?: PoolClusterOptions): PoolCluster;

typings/mysql/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import {
1313
PoolCluster as BasePoolCluster,
1414
PoolClusterOptions,
15+
PoolNamespace,
1516
} from './lib/PoolCluster.js';
1617
import { PoolConnection as BasePoolConnection } from './lib/PoolConnection.js';
1718
import {
@@ -25,6 +26,7 @@ export {
2526
SslOptions,
2627
PoolOptions,
2728
PoolClusterOptions,
29+
PoolNamespace,
2830
QueryOptions,
2931
QueryError,
3032
PrepareStatementInfo,

0 commit comments

Comments
 (0)