MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / remove

Method remove

lib/host-connection-pool.js:309–325  ·  view source on GitHub ↗

* Closes the connection and removes a connection from the pool. * @param {Connection} connection

(connection)

Source from the content-addressed store, hash-verified

307 * @param {Connection} connection
308 */
309 remove(connection) {
310 // locating an object by position in the array is O(n), but normally there should be between 1 to 8 connections.
311 const index = this.connections.indexOf(connection);
312 if (index < 0) {
313 // it was already removed from the connections and it's closing
314 return;
315 }
316 // remove the connection from the pool, using an pool copy
317 const newConnections = this.connections.slice(0);
318 newConnections.splice(index, 1);
319 this.connections = newConnections;
320 // close the connection
321 setImmediate(function removeClose() {
322 connection.close();
323 });
324 this.emit('remove');
325 }
326
327 /**
328 * @param {Number} delay

Callers

nothing calls this directly

Calls 2

closeMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected