* Creates a new instance from the provided client. * @param {Client} client * @internal * @ignore
(client)
| 95 | * @ignore |
| 96 | */ |
| 97 | static from(client) { |
| 98 | const openConnections = {}; |
| 99 | const inFlightQueries = {}; |
| 100 | const hostArray = []; |
| 101 | |
| 102 | client.hosts.forEach(host => { |
| 103 | if (host.pool.connections.length === 0) { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | hostArray.push(host); |
| 108 | openConnections[host.address] = host.pool.connections.length; |
| 109 | inFlightQueries[host.address] = host.getInFlight(); |
| 110 | }); |
| 111 | |
| 112 | return new ClientState(hostArray, openConnections, inFlightQueries); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | module.exports = ClientState; |
no test coverage detected