sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.51k stars 82 forks source link

Add a `connections()` method to `Pool` #26

Closed rushmorem closed 8 years ago

rushmorem commented 8 years ago

This method simply returns the number of connections currently open. This is very useful for health checking the pool as a whole. If, for example, this method consistently returns a number less than min_idle it means you are in trouble. If it falls to zero then none of your servers is up. A good use case for this is monitoring your servers.

While the same info is included when you debug print the pool, which is very helpful during development to track down a bug, exposing this info in a public method like this makes it feasible to act on it in production.

sfackler commented 8 years ago

This does seem useful! Could you add a similar method returning the number of idle connections? Looks good to me other than that.

rushmorem commented 8 years ago

OK, let me do that.

rushmorem commented 8 years ago

I have added idle_connections() as well as config(). I realised that there was no way to query the current configuration which helps make the most of these methods so I added it.

sfackler commented 8 years ago

Thanks!