Close the pool
()
| 489 | |
| 490 | /** Close the pool */ |
| 491 | close(): void { |
| 492 | if (this.closed) { |
| 493 | return; |
| 494 | } |
| 495 | |
| 496 | // immediately cancel any in-flight connections |
| 497 | this.cancellationToken.emit('cancel'); |
| 498 | |
| 499 | // end the connection counter |
| 500 | if (typeof this.connectionCounter.return === 'function') { |
| 501 | this.connectionCounter.return(undefined); |
| 502 | } |
| 503 | |
| 504 | this.poolState = PoolState.closed; |
| 505 | this.clearMinPoolSizeTimer(); |
| 506 | this.processWaitQueue(); |
| 507 | |
| 508 | for (const conn of this.connections) { |
| 509 | this.emitAndLog( |
| 510 | ConnectionPool.CONNECTION_CLOSED, |
| 511 | new ConnectionClosedEvent(this, conn, 'poolClosed') |
| 512 | ); |
| 513 | conn.destroy(); |
| 514 | } |
| 515 | this.connections.clear(); |
| 516 | this.emitAndLog(ConnectionPool.CONNECTION_POOL_CLOSED, new ConnectionPoolClosedEvent(this)); |
| 517 | } |
| 518 | |
| 519 | /** |
| 520 | * @internal |
no test coverage detected