MCPcopy
hub / github.com/mongodb/node-mongodb-native / checkIn

Method checkIn

src/cmap/connection_pool.ts:384–409  ·  view source on GitHub ↗

* Check a connection into the pool. * * @param connection - The connection to check in

(connection: Connection)

Source from the content-addressed store, hash-verified

382 * @param connection - The connection to check in
383 */
384 checkIn(connection: Connection): void {
385 if (!this.checkedOut.has(connection)) {
386 return;
387 }
388 const poolClosed = this.closed;
389 const stale = this.connectionIsStale(connection);
390 const willDestroy = !!(poolClosed || stale || connection.closed);
391
392 if (!willDestroy) {
393 connection.markAvailable();
394 this.connections.unshift(connection);
395 }
396
397 this.checkedOut.delete(connection);
398 this.emitAndLog(
399 ConnectionPool.CONNECTION_CHECKED_IN,
400 new ConnectionCheckedInEvent(this, connection)
401 );
402
403 if (willDestroy) {
404 const reason = connection.closed ? 'error' : poolClosed ? 'poolClosed' : 'stale';
405 this.destroyConnection(connection, reason);
406 }
407
408 queueMicrotask(() => this.processWaitQueue());
409 }
410
411 /**
412 * Clear the pool

Callers 8

getTestOpDefinitionsFunction · 0.80
_connectMethod · 0.80
checkBackInMethod · 0.80
cleanupMethod · 0.80

Calls 8

connectionIsStaleMethod · 0.95
destroyConnectionMethod · 0.95
processWaitQueueMethod · 0.95
markAvailableMethod · 0.80
unshiftMethod · 0.80
emitAndLogMethod · 0.80
hasMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected