@@ -291,7 +291,15 @@ class Topology extends EventEmitter {
291
291
* Close this topology
292
292
*/
293
293
close ( options , callback ) {
294
- if ( typeof options === 'function' ) ( callback = options ) , ( options = { } ) ;
294
+ if ( typeof options === 'function' ) {
295
+ callback = options ;
296
+ options = { } ;
297
+ }
298
+
299
+ if ( typeof options === 'boolean' ) {
300
+ options = { force : options } ;
301
+ }
302
+
295
303
options = options || { } ;
296
304
297
305
// clear all existing monitor timers
@@ -332,7 +340,7 @@ class Topology extends EventEmitter {
332
340
// destroy all child servers
333
341
let destroyed = 0 ;
334
342
servers . forEach ( server =>
335
- destroyServer ( server , this , ( ) => {
343
+ destroyServer ( server , this , options , ( ) => {
336
344
destroyed ++ ;
337
345
if ( destroyed === servers . size ) {
338
346
// emit an event for close
@@ -736,10 +744,11 @@ function isWriteCommand(command) {
736
744
*
737
745
* @param {Server } server
738
746
*/
739
- function destroyServer ( server , topology , callback ) {
747
+ function destroyServer ( server , topology , options , callback ) {
748
+ options = options || { } ;
740
749
LOCAL_SERVER_EVENTS . forEach ( event => server . removeAllListeners ( event ) ) ;
741
750
742
- server . destroy ( ( ) => {
751
+ server . destroy ( options , ( ) => {
743
752
topology . emit (
744
753
'serverClosed' ,
745
754
new monitoring . ServerClosedEvent ( topology . s . id , server . description . address )
0 commit comments