@@ -28,13 +28,17 @@ import { HostInfo } from "../../../common/lib/host_info";
2828
2929export class NodePostgresDriverDialect implements DriverDialect {
3030 protected dialectName : string = this . constructor . name ;
31+ private static keepAlivePropertyName = "keepAlive" ;
32+ private static keepAliveInitialDelayMillisPropertyName = "keepAliveInitialDelayMillis" ;
3133
3234 getDialectName ( ) : string {
3335 return this . dialectName ;
3436 }
3537
3638 async connect ( hostInfo : HostInfo , props : Map < string , any > ) : Promise < ClientWrapper > {
37- 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 ) ;
3842 await targetClient . connect ( ) ;
3943 return Promise . resolve ( new PgClientWrapper ( targetClient , hostInfo , props ) ) ;
4044 }
@@ -55,4 +59,20 @@ export class NodePostgresDriverDialect implements DriverDialect {
5559 getAwsPoolClient ( props : pkgPg . PoolConfig ) : AwsPoolClient {
5660 return new AwsPgPoolClient ( props ) ;
5761 }
62+
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 ) ;
76+ }
77+ }
5878}
0 commit comments