leoric icon indicating copy to clipboard operation
leoric copied to clipboard

[feat] connection pool info API

Open JimmyDaddy opened this issue 2 years ago • 4 comments

getConnectionSize()/getPoolSize() ?
getAvailableConnections() ?
getWaitingConnections() ?

JimmyDaddy avatar Sep 22 '21 08:09 JimmyDaddy

I'd prefer adhering to existing pool api of mysqljs/mysql with few options like initialSize and idleTimeout added. To implement a customized pool layer isn't very complicated, I think it's time for us to start.

cyjake avatar Sep 23 '21 02:09 cyjake

For example, the proposed api in issue description can mostly be replaced with

proposed possible existence
getConnectionSize()/getPoolSize() pool.options.connectionLimit
getAvailableConnections() pool.connections.length
getWaitingConnections() N/A

Does getWaitingConnections() mean idle connections? If so we need two connections arrays, idleConnections and connections.

cyjake avatar Sep 23 '21 02:09 cyjake

getAvailableConnections() means idle connections, getWaitingConnections() means waiting connections, in Sequelize is waitingClientsCount, in pg those three readonly variables' names are properly:

 readonly totalCount: number;
 readonly idleCount: number;
 readonly waitingCount: number;

JimmyDaddy avatar Sep 23 '21 02:09 JimmyDaddy

waitingClientsCount or waitingCount does not mean waiting connections, which rather mean waiting queries that are postponed while all connections are checked out.

cyjake avatar Sep 23 '21 03:09 cyjake