sfackler / r2d2

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

Event for all connections closed #97

Closed tkaitchuck closed 4 years ago

tkaitchuck commented 4 years ago

Would it be possible to get an even for the HandleEvent trait set via the event_handler to get notified if all the connections are closed? Or perhaps it could just notify on connection close, as it would be then easy to get the State of the pool.

This would be helpful as a way to clean up pools for endpoints that are no longer being used.

sfackler commented 4 years ago

handle_release is called when connections close, so with that along with handle_acquire, your event handler should be able to figure out when there are no active connections: https://docs.rs/r2d2/0.8.8/r2d2/event/trait.HandleEvent.html#method.handle_release