Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move enableKeepAlive and keepAliveInitialDelay options to `C… #2288

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { mysql, mysqlp } from '../index.js';

// Callback
(() => {
const poolOptions: mysql.PoolOptions = {
enableKeepAlive: true,
keepAliveInitialDelay: 0,
}

const connectionOptions: mysql.ConnectionOptions = {
enableKeepAlive: true,
keepAliveInitialDelay: 0,
}

mysql.createConnection(connectionOptions);
mysql.createPool(poolOptions);
mysql.createPoolCluster().add(poolOptions);
})();

// Promise
(() => {
const poolOptions: mysqlp.PoolOptions = {
enableKeepAlive: true,
keepAliveInitialDelay: 0,
}

const connectionOptions: mysqlp.ConnectionOptions = {
enableKeepAlive: true,
keepAliveInitialDelay: 0,
}

mysqlp.createConnection(connectionOptions);
mysqlp.createPool(poolOptions);
mysqlp.createPoolCluster().add(poolOptions);
})();
30 changes: 24 additions & 6 deletions typings/mysql/lib/Connection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ export interface ConnectionOptions {
*/
rowsAsArray?: boolean;

/**
* 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;

charsetNumber?: number;

compress?: boolean;
Expand Down Expand Up @@ -312,22 +322,30 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {
| RowDataPacket[]
| OkPacket
| OkPacket[]
| ResultSetHeader
| ResultSetHeader,
>(
sql: string,
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
callback?: (
err: QueryError | null,
result: T,
fields: FieldPacket[],
) => any,
): Query;
static createQuery<
T extends
| RowDataPacket[][]
| RowDataPacket[]
| OkPacket
| OkPacket[]
| ResultSetHeader
| ResultSetHeader,
>(
sql: string,
values: any | any[] | { [param: string]: any },
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
callback?: (
err: QueryError | null,
result: T,
fields: FieldPacket[],
) => any,
): Query;

beginTransaction(callback: (err: QueryError | null) => void): void;
Expand All @@ -338,7 +356,7 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {

changeUser(
options: ConnectionOptions,
callback?: (err: QueryError | null) => void
callback?: (err: QueryError | null) => void,
): void;

end(callback?: (err: QueryError | null) => void): void;
Expand All @@ -363,7 +381,7 @@ declare class Connection extends QueryableBase(ExecutableBase(EventEmitter)) {

prepare(
sql: string,
callback?: (err: QueryError | null, statement: PrepareStatementInfo) => any
callback?: (err: QueryError | null, statement: PrepareStatementInfo) => any,
): Prepare;

unprepare(sql: string): PrepareStatementInfo;
Expand Down
10 changes: 0 additions & 10 deletions typings/mysql/lib/Pool.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ export interface PoolOptions extends ConnectionOptions {
* 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)) {
Expand Down
Loading