(client, pendingItem, idleListener)
| 309 | } |
| 310 | |
| 311 | _afterConnect(client, pendingItem, idleListener) { |
| 312 | if (this.options.maxLifetimeSeconds !== 0) { |
| 313 | const maxLifetimeTimeout = setTimeout(() => { |
| 314 | this.log('ending client due to expired lifetime') |
| 315 | this._expired.add(client) |
| 316 | const idleIndex = this._idle.findIndex((idleItem) => idleItem.client === client) |
| 317 | if (idleIndex !== -1) { |
| 318 | this._acquireClient( |
| 319 | client, |
| 320 | new PendingItem((err, client, clientRelease) => clientRelease()), |
| 321 | idleListener, |
| 322 | false |
| 323 | ) |
| 324 | } |
| 325 | }, this.options.maxLifetimeSeconds * 1000) |
| 326 | |
| 327 | maxLifetimeTimeout.unref() |
| 328 | client.once('end', () => clearTimeout(maxLifetimeTimeout)) |
| 329 | } |
| 330 | |
| 331 | return this._acquireClient(client, pendingItem, idleListener, true) |
| 332 | } |
| 333 | |
| 334 | // acquire a client for a pending work item |
| 335 | _acquireClient(client, pendingItem, idleListener, isNew) { |
no test coverage detected