File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,15 @@ import knex, { Knex } from 'knex'
44import { createLogger } from '../factories/logger-factory'
55
66( ( knex ) => {
7- const counters = { }
7+ const lastUpdate = { }
88 knex . Client . prototype . releaseConnection = function ( connection ) {
99 const released = this . pool . release ( connection )
1010
1111 if ( released ) {
12- counters [ this . config . tag ] = ( counters [ this . config . tag ] ?? 0 ) + 1
13- if ( counters [ this . config . tag ] % 10 === 0 ) {
12+ const now = new Date ( ) . getTime ( )
13+ lastUpdate [ this . config . tag ] = lastUpdate [ this . config . tag ] ?? now
14+ if ( now - lastUpdate [ this . config . tag ] >= 60000 ) {
15+ lastUpdate [ this . config . tag ] = now
1416 console . log ( `${ this . config . tag } connection pool: ${ this . pool . numUsed ( ) } used / ${ this . pool . numFree ( ) } free / ${ this . pool . numPendingAcquires ( ) } pending` )
1517 }
1618 }
You can’t perform that action at this time.
0 commit comments