Skip to content

Commit 90181b1

Browse files
refactor: make Pool.clear take options object
1 parent c438bcf commit 90181b1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/cmap/connection_pool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
408408
* Pool reset is handled by incrementing the pool's generation count. Any existing connection of a
409409
* previous generation will eventually be pruned during subsequent checkouts.
410410
*/
411-
clear(serviceId?: ObjectId): void {
411+
clear(options: { serviceId?: ObjectId } = {}): void {
412+
const { serviceId } = options;
412413
if (this.closed) {
413414
return;
414415
}

src/sdam/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,14 @@ export class Server extends TypedEventEmitter<ServerEvents> {
400400
error.addErrorLabel(MongoErrorLabel.ResetPool);
401401
markServerUnknown(this, error);
402402
} else if (connection) {
403-
this.s.pool.clear(connection.serviceId);
403+
this.s.pool.clear({ serviceId: connection.serviceId });
404404
}
405405
} else {
406406
if (isSDAMUnrecoverableError(error)) {
407407
if (shouldHandleStateChangeError(this, error)) {
408408
const shouldClearPool = maxWireVersion(this) <= 7 || isNodeShuttingDownError(error);
409409
if (this.loadBalanced && connection && shouldClearPool) {
410-
this.s.pool.clear(connection.serviceId);
410+
this.s.pool.clear({ serviceId: connection.serviceId });
411411
}
412412

413413
if (!this.loadBalanced) {

src/sessions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export function maybeClearPinnedConnection(
537537
);
538538

539539
if (options?.forceClear) {
540-
loadBalancer.s.pool.clear(conn.serviceId);
540+
loadBalancer.s.pool.clear({ serviceId: conn.serviceId });
541541
}
542542
}
543543

0 commit comments

Comments
 (0)