MCPcopy
hub / github.com/brianc/node-postgres / _afterConnect

Method _afterConnect

packages/pg-pool/index.js:311–332  ·  view source on GitHub ↗
(client, pendingItem, idleListener)

Source from the content-addressed store, hash-verified

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) {

Callers 1

newClientMethod · 0.95

Calls 3

_acquireClientMethod · 0.95
addMethod · 0.45
unrefMethod · 0.45

Tested by

no test coverage detected