From 90181b147c6458b954c23c4ec11ce9410e13e556 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 24 Oct 2022 11:32:12 -0400 Subject: [PATCH] refactor: make Pool.clear take options object --- src/cmap/connection_pool.ts | 3 ++- src/sdam/server.ts | 4 ++-- src/sessions.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cmap/connection_pool.ts b/src/cmap/connection_pool.ts index f621b4f9b4c..d7f7e70406e 100644 --- a/src/cmap/connection_pool.ts +++ b/src/cmap/connection_pool.ts @@ -408,7 +408,8 @@ export class ConnectionPool extends TypedEventEmitter { * Pool reset is handled by incrementing the pool's generation count. Any existing connection of a * previous generation will eventually be pruned during subsequent checkouts. */ - clear(serviceId?: ObjectId): void { + clear(options: { serviceId?: ObjectId } = {}): void { + const { serviceId } = options; if (this.closed) { return; } diff --git a/src/sdam/server.ts b/src/sdam/server.ts index a693bf3bc8f..a2930caf8bc 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -400,14 +400,14 @@ export class Server extends TypedEventEmitter { error.addErrorLabel(MongoErrorLabel.ResetPool); markServerUnknown(this, error); } else if (connection) { - this.s.pool.clear(connection.serviceId); + this.s.pool.clear({ serviceId: connection.serviceId }); } } else { if (isSDAMUnrecoverableError(error)) { if (shouldHandleStateChangeError(this, error)) { const shouldClearPool = maxWireVersion(this) <= 7 || isNodeShuttingDownError(error); if (this.loadBalanced && connection && shouldClearPool) { - this.s.pool.clear(connection.serviceId); + this.s.pool.clear({ serviceId: connection.serviceId }); } if (!this.loadBalanced) { diff --git a/src/sessions.ts b/src/sessions.ts index 312c744cd80..aad29962171 100644 --- a/src/sessions.ts +++ b/src/sessions.ts @@ -537,7 +537,7 @@ export function maybeClearPinnedConnection( ); if (options?.forceClear) { - loadBalancer.s.pool.clear(conn.serviceId); + loadBalancer.s.pool.clear({ serviceId: conn.serviceId }); } }