(options)
| 318 | } |
| 319 | |
| 320 | createPool(options) { |
| 321 | this.pool = new ConnectionPool(this.#server, { |
| 322 | ...this.#poolOptions, |
| 323 | ...options, |
| 324 | hostAddress: this.#hostAddress, |
| 325 | serverApi: process.env.MONGODB_API_VERSION |
| 326 | ? { version: process.env.MONGODB_API_VERSION } |
| 327 | : undefined, |
| 328 | metadata: this.#server.topology.client.options.metadata |
| 329 | }); |
| 330 | this.#originalServerPool = this.#server.pool; |
| 331 | this.#server.pool = this.pool; |
| 332 | ALL_POOL_EVENTS.forEach(eventName => { |
| 333 | this.pool.on(eventName, event => { |
| 334 | if (this.#injectPoolStats) { |
| 335 | event.totalConnectionCount = this.pool.totalConnectionCount; |
| 336 | event.availableConnectionCount = this.pool.availableConnectionCount; |
| 337 | event.pendingConnectionCount = this.pool.pendingConnectionCount; |
| 338 | event.currentCheckedOutCount = this.pool.currentCheckedOutCount; |
| 339 | } |
| 340 | this.poolEvents.push(event); |
| 341 | this.poolEventsEventEmitter.emit('poolEvent'); |
| 342 | }); |
| 343 | }); |
| 344 | } |
| 345 | |
| 346 | closePool() { |
| 347 | this.#server.pool = this.#originalServerPool; |
no test coverage detected