@@ -134,38 +134,25 @@ export type ConnectionPoolEvents = {
134
134
*/
135
135
export class ConnectionPool extends TypedEventEmitter < ConnectionPoolEvents > {
136
136
options : Readonly < ConnectionPoolOptions > ;
137
- /** @internal */
138
137
[ kPoolState ] : typeof PoolState [ keyof typeof PoolState ] ;
139
- /** @internal */
140
138
[ kServer ] : Server ;
141
- /** @internal */
142
139
[ kLogger ] : Logger ;
143
- /** @internal */
144
140
[ kConnections ] : Denque < Connection > ;
145
- /** @internal */
146
141
[ kPending ] : number ;
147
- /** @internal */
148
- [ kCheckedOut ] : number ;
149
- /** @internal */
142
+ [ kCheckedOut ] : Set < Connection > ;
150
143
[ kMinPoolSizeTimer ] ?: NodeJS . Timeout ;
151
144
/**
152
145
* An integer representing the SDAM generation of the pool
153
- * @internal
154
146
*/
155
147
[ kGeneration ] : number ;
156
- /** A map of generations to service ids
157
- * @internal
148
+ /**
149
+ * A map of generations to service ids
158
150
*/
159
151
[ kServiceGenerations ] : Map < string , number > ;
160
- /** @internal */
161
152
[ kConnectionCounter ] : Generator < number > ;
162
- /** @internal */
163
153
[ kCancellationToken ] : CancellationToken ;
164
- /** @internal */
165
154
[ kWaitQueue ] : Denque < WaitQueueMember > ;
166
- /** @internal */
167
155
[ kMetrics ] : ConnectionPoolMetrics ;
168
- /** @internal */
169
156
[ kProcessingWaitQueue ] : boolean ;
170
157
171
158
/**
@@ -224,7 +211,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
224
211
*/
225
212
static readonly CONNECTION_CHECKED_IN = CONNECTION_CHECKED_IN ;
226
213
227
- /** @internal */
228
214
constructor ( server : Server , options : ConnectionPoolOptions ) {
229
215
super ( ) ;
230
216
@@ -252,7 +238,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
252
238
this [ kLogger ] = new Logger ( 'ConnectionPool' ) ;
253
239
this [ kConnections ] = new Denque ( ) ;
254
240
this [ kPending ] = 0 ;
255
- this [ kCheckedOut ] = 0 ;
241
+ this [ kCheckedOut ] = new Set ( ) ;
256
242
this [ kMinPoolSizeTimer ] = undefined ;
257
243
this [ kGeneration ] = 0 ;
258
244
this [ kServiceGenerations ] = new Map ( ) ;
@@ -304,7 +290,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
304
290
}
305
291
306
292
get currentCheckedOutCount ( ) : number {
307
- return this [ kCheckedOut ] ;
293
+ return this [ kCheckedOut ] . size ;
308
294
}
309
295
310
296
get waitQueueSize ( ) : number {
@@ -323,6 +309,17 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
323
309
return this [ kServer ] . description . error ;
324
310
}
325
311
312
+ /**
313
+ * This is exposed ONLY for use in mongosh, to enable
314
+ * killing all connections if a user quits the shell with
315
+ * operations in progress.
316
+ *
317
+ * This property may be removed as a part of NODE-3263.
318
+ */
319
+ get checkedOutConnections ( ) {
320
+ return this [ kCheckedOut ] ;
321
+ }
322
+
326
323
/**
327
324
* Get the metrics information for the pool when a wait queue timeout occurs.
328
325
*/
@@ -395,7 +392,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
395
392
this [ kConnections ] . unshift ( connection ) ;
396
393
}
397
394
398
- this [ kCheckedOut ] -- ;
395
+ this [ kCheckedOut ] . delete ( connection ) ;
399
396
this . emit ( ConnectionPool . CONNECTION_CHECKED_IN , new ConnectionCheckedInEvent ( this , connection ) ) ;
400
397
401
398
if ( willDestroy ) {
@@ -744,7 +741,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
744
741
}
745
742
746
743
if ( ! this . connectionIsPerished ( connection ) ) {
747
- this [ kCheckedOut ] ++ ;
744
+ this [ kCheckedOut ] . add ( connection ) ;
748
745
this . emit (
749
746
ConnectionPool . CONNECTION_CHECKED_OUT ,
750
747
new ConnectionCheckedOutEvent ( this , connection )
@@ -780,7 +777,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
780
777
new ConnectionCheckOutFailedEvent ( this , 'connectionError' )
781
778
) ;
782
779
} else if ( connection ) {
783
- this [ kCheckedOut ] ++ ;
780
+ this [ kCheckedOut ] . add ( connection ) ;
784
781
this . emit (
785
782
ConnectionPool . CONNECTION_CHECKED_OUT ,
786
783
new ConnectionCheckedOutEvent ( this , connection )
0 commit comments