@@ -52,21 +52,34 @@ function Postgres(a, b) {
52
52
53
53
let ending = false
54
54
55
- const queries = Queue ( )
56
- , connecting = Queue ( )
57
- , reserved = Queue ( )
58
- , closed = Queue ( )
59
- , ended = Queue ( )
60
- , open = Queue ( )
61
- , busy = Queue ( )
62
- , full = Queue ( )
55
+ const queries = Queue ( 'queries' )
56
+ , connecting = Queue ( 'connecting' )
57
+ , reserved = Queue ( 'reserved' )
58
+ , closed = Queue ( 'closed' )
59
+ , ended = Queue ( 'ended' )
60
+ , open = Queue ( 'open' )
61
+ , busy = Queue ( 'busy' )
62
+ , full = Queue ( 'full' )
63
63
, queues = { connecting, reserved, closed, ended, open, busy, full }
64
64
65
65
const connections = [ ...Array ( options . max ) ] . map ( ( ) => Connection ( options , queues , { onopen, onend, onclose } ) )
66
66
67
67
const sql = Sql ( handler )
68
68
69
69
Object . assign ( sql , {
70
+ queries,
71
+ connections : {
72
+ onchange : null ,
73
+ max : options . max ,
74
+ get open ( ) { return reserved . length + open . length + busy . length + full . length } ,
75
+ get connecting ( ) { return connecting . length } ,
76
+ get ended ( ) { return ended . length } ,
77
+ get closed ( ) { return closed . length } ,
78
+ get reserved ( ) { return reserved . length } ,
79
+ get idle ( ) { return open . length } ,
80
+ get busy ( ) { return busy . length } ,
81
+ get full ( ) { return full . length }
82
+ } ,
70
83
get parameters ( ) { return options . parameters } ,
71
84
largeObject : largeObject . bind ( null , sql ) ,
72
85
subscribe,
@@ -308,6 +321,8 @@ function Postgres(a, b) {
308
321
queue === open
309
322
? c . idleTimer . start ( )
310
323
: c . idleTimer . cancel ( )
324
+
325
+ sql . connections . onchange && sql . connections . onchange ( queue . name )
311
326
return c
312
327
}
313
328
0 commit comments