@@ -37,6 +37,7 @@ import { logger } from "../logutils";
37
37
import { RoundRobinHostSelector } from "./round_robin_host_selector" ;
38
38
import { AwsPoolClient } from "./aws_pool_client" ;
39
39
import { AwsPoolConfig } from "./aws_pool_config" ;
40
+ import { PoolClientWrapper } from "./pool_client_wrapper" ;
40
41
41
42
export class InternalPooledConnectionProvider implements PooledConnectionProvider , CanReleaseResources {
42
43
private static readonly acceptedStrategies : Map < string , HostSelector > = new Map ( [
@@ -108,28 +109,16 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
108
109
const preparedConfig = dialect . preparePoolClientProperties ( props , this . _poolConfig ) ;
109
110
110
111
this . internalPool = this . databasePools . computeIfAbsent (
111
- new PoolKey ( hostInfo . url , this . getPoolKey ( hostInfo , props ) ) ,
112
+ new PoolKey ( connectionHostInfo . url , this . getPoolKey ( connectionHostInfo , props ) ) ,
112
113
( ) => dialect . getAwsPoolClient ( preparedConfig ) ,
113
114
this . poolExpirationCheckNanos
114
115
) ;
115
116
116
- const poolClient = await this . getPoolConnection ( ) ;
117
-
118
- return {
119
- client : poolClient ,
120
- hostInfo : connectionHostInfo ,
121
- properties : props
122
- } ;
123
- }
124
-
125
- async end ( pluginService : PluginService , clientWrapper : ClientWrapper | undefined ) : Promise < void > {
126
- if ( this . internalPool && clientWrapper ) {
127
- return this . internalPool . end ( clientWrapper . client ) ;
128
- }
117
+ return await this . getPoolConnection ( hostInfo , props ) ;
129
118
}
130
119
131
- async getPoolConnection ( ) {
132
- return this . internalPool ! . connect ( ) ;
120
+ async getPoolConnection ( hostInfo : HostInfo , props : Map < string , string > ) {
121
+ return new PoolClientWrapper ( await this . internalPool ! . connect ( ) , hostInfo , props ) ;
133
122
}
134
123
135
124
public async releaseResources ( ) {
@@ -172,17 +161,12 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
172
161
}
173
162
174
163
logConnections ( ) {
175
- for ( const [ key , val ] of this . databasePools . entries ) {
176
- logger . debug (
177
- "Internal Pooled Connection: \t\n[ " +
178
- key . getPoolKeyString ( ) +
179
- "\n\t {\n\t\t\t" +
180
- JSON . stringify ( val . item . constructor . name ) +
181
- "\t(expirationTimeNs: " +
182
- val . expirationTimeNs +
183
- ")\n\t }\n]"
184
- ) ;
164
+ if ( this . databasePools . size === 0 ) {
165
+ return ;
185
166
}
167
+
168
+ const l = Array . from ( this . databasePools . entries ) . map ( ( [ v , k ] ) => [ v . getPoolKeyString ( ) , k . item . constructor . name ] ) ;
169
+ logger . debug ( `Internal Pooled Connection: [${ JSON . stringify ( l ) } ]` ) ;
186
170
}
187
171
188
172
setDatabasePools ( connectionPools : SlidingExpirationCache < PoolKey , any > ) : void {
0 commit comments