* This will close all open connections and set a terminated status in the pool * * ```ts * import { Pool } from "jsr:@db/postgres"; * const pool = new Pool({}, 10); * * await pool.end(); * console.assert(pool.available === 0, "There are connections available after ending the poo
()
| 167 | * ``` |
| 168 | */ |
| 169 | async end(): Promise<void> { |
| 170 | if (this.#ended) { |
| 171 | throw new Error("Pool connections have already been terminated"); |
| 172 | } |
| 173 | |
| 174 | await this.#ready; |
| 175 | while (this.available > 0) { |
| 176 | const client = await this.#available_connections!.pop(); |
| 177 | await client.end(); |
| 178 | } |
| 179 | |
| 180 | this.#available_connections = undefined; |
| 181 | this.#ended = true; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Initialization will create all pool clients instances by default |
no test coverage detected