Skip to content

Commit

Permalink
fix: PoolCluster typings
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed Jun 24, 2023
1 parent b2c5b49 commit 3902ca6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion typings/mysql/lib/PoolCluster.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
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 {
/**
Expand Down Expand Up @@ -29,10 +36,20 @@ export interface PoolClusterOptions {
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;
Expand All @@ -59,7 +76,7 @@ declare class PoolCluster extends EventEmitter {
) => void
): void;

of(pattern: string, selector?: string): PoolCluster;
of(pattern: string, selector?: string): PoolNamespace;

on(event: string, listener: (args: any[]) => void): this;
on(event: 'remove', listener: (nodeId: number) => void): this;
Expand Down

0 comments on commit 3902ca6

Please sign in to comment.