Skip to content

Commit c9b9aa1

Browse files
committed
chore: reorder keep alive properties settings
1 parent 7875c21 commit c9b9aa1

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

common/lib/driver_dialect/driver_dialect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export interface DriverDialect {
2828

2929
getAwsPoolClient(props: any): AwsPoolClient;
3030

31-
setKeepAliveProperties(props: Map<string, any>): void;
31+
setKeepAliveProperties(props: Map<string, any>, keepAliveProps: any): void;
3232
}

mysql/lib/dialect/mysql2_driver_dialect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ export class MySQL2DriverDialect implements DriverDialect {
5353
return new AwsMysqlPoolClient(props);
5454
}
5555

56-
setKeepAliveProperties(props: Map<string, any>) {}
56+
setKeepAliveProperties(props: Map<string, any>, keepAliveProps: any) {}
5757
}

pg/lib/dialect/node_postgres_driver_dialect.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export class NodePostgresDriverDialect implements DriverDialect {
3636
}
3737

3838
async connect(hostInfo: HostInfo, props: Map<string, any>): Promise<ClientWrapper> {
39-
this.setKeepAliveProperties(props);
40-
const targetClient = new pkgPg.Client(WrapperProperties.removeWrapperProperties(props));
39+
const driverProperties = WrapperProperties.removeWrapperProperties(props);
40+
this.setKeepAliveProperties(driverProperties, props.get(WrapperProperties.KEEPALIVE_PROPERTIES.name));
41+
const targetClient = new pkgPg.Client(driverProperties);
4142
await targetClient.connect();
4243
return Promise.resolve(new PgClientWrapper(targetClient, hostInfo, props));
4344
}
@@ -59,15 +60,19 @@ export class NodePostgresDriverDialect implements DriverDialect {
5960
return new AwsPgPoolClient(props);
6061
}
6162

62-
setKeepAliveProperties(props: Map<string, any>) {
63-
if (props.has(WrapperProperties.KEEPALIVE_PROPERTIES.name)) {
64-
const keepAliveProps = props.get(WrapperProperties.KEEPALIVE_PROPERTIES.name);
65-
props.set(NodePostgresDriverDialect.keepAlivePropertyName, keepAliveProps.get(NodePostgresDriverDialect.keepAlivePropertyName));
66-
props.set(
67-
NodePostgresDriverDialect.keepAliveInitialDelayMillisPropertyName,
68-
keepAliveProps.get(NodePostgresDriverDialect.keepAliveInitialDelayMillisPropertyName)
69-
);
70-
props.delete(WrapperProperties.KEEPALIVE_PROPERTIES.name);
63+
setKeepAliveProperties(props: Map<string, any>, keepAliveProps: any) {
64+
if (!keepAliveProps) {
65+
return;
66+
}
67+
68+
const keepAlive = keepAliveProps.get(NodePostgresDriverDialect.keepAlivePropertyName);
69+
const keepAliveInitialDelayMillis = keepAliveProps.get(NodePostgresDriverDialect.keepAliveInitialDelayMillisPropertyName);
70+
71+
if (keepAlive) {
72+
props.set(NodePostgresDriverDialect.keepAlivePropertyName, keepAlive);
73+
}
74+
if (keepAliveInitialDelayMillis) {
75+
props.set(NodePostgresDriverDialect.keepAliveInitialDelayMillisPropertyName, keepAliveInitialDelayMillis);
7176
}
7277
}
7378
}

0 commit comments

Comments
 (0)