2
2
3
3
const Denque = require ( 'denque' ) ;
4
4
const EventEmitter = require ( 'events' ) . EventEmitter ;
5
+ const Logger = require ( '../core/connection/logger' ) ;
5
6
const makeCounter = require ( '../utils' ) . makeCounter ;
6
7
const MongoError = require ( '../core/error' ) . MongoError ;
7
8
const Connection = require ( './connection' ) . Connection ;
@@ -25,6 +26,7 @@ const ConnectionCheckedOutEvent = events.ConnectionCheckedOutEvent;
25
26
const ConnectionCheckedInEvent = events . ConnectionCheckedInEvent ;
26
27
const ConnectionPoolClearedEvent = events . ConnectionPoolClearedEvent ;
27
28
29
+ const kLogger = Symbol ( 'logger' ) ;
28
30
const kConnections = Symbol ( 'connections' ) ;
29
31
const kPermits = Symbol ( 'permits' ) ;
30
32
const kMinPoolSizeTimer = Symbol ( 'minPoolSizeTimer' ) ;
@@ -159,9 +161,12 @@ class ConnectionPool extends EventEmitter {
159
161
} ) ;
160
162
161
163
if ( options . minSize > options . maxSize ) {
162
- throw new TypeError ( 'Pool minimum size must not be greater than maxiumum pool size' ) ;
164
+ throw new TypeError (
165
+ 'Connection pool minimum size must not be greater than maxiumum pool size'
166
+ ) ;
163
167
}
164
168
169
+ this [ kLogger ] = Logger ( 'ConnectionPool' , options ) ;
165
170
this [ kConnections ] = new Denque ( ) ;
166
171
this [ kPermits ] = this . options . maxPoolSize ;
167
172
this [ kMinPoolSizeTimer ] = undefined ;
@@ -354,11 +359,6 @@ class ConnectionPool extends EventEmitter {
354
359
get address ( ) {
355
360
return `${ this . options . host } :${ this . options . port } ` ;
356
361
}
357
-
358
- // Private Helpers
359
- _propagateError ( ) {
360
- return ;
361
- }
362
362
}
363
363
364
364
function ensureMinPoolSize ( pool ) {
@@ -395,9 +395,7 @@ function createConnection(pool, callback) {
395
395
connect ( connectOptions , pool [ kCancellationToken ] , ( err , connection ) => {
396
396
if ( err ) {
397
397
pool [ kPermits ] ++ ;
398
-
399
- // NOTE: integrate logger here
400
- pool . _propagateError ( err ) ;
398
+ pool [ kLogger ] . debug ( `connection attempt failed with error [${ JSON . stringify ( err ) } ]` ) ;
401
399
if ( typeof callback === 'function' ) {
402
400
callback ( err ) ;
403
401
}
0 commit comments