decrement pool size when connection is released

This commit is contained in:
Andrew Whitehead 2020-12-17 21:57:03 -08:00 committed by Ryan Leckey
parent 4c1cf86380
commit f39d194b17
No known key found for this signature in database
GPG key ID: F8AA68C235AB08C9

View file

@ -56,9 +56,13 @@ impl<DB: Database> DerefMut for PoolConnection<DB> {
}
impl<DB: Database> PoolConnection<DB> {
// explicitly release a connection from the pool
/// Explicitly release a connection from the pool
pub fn release(mut self) -> DB::Connection {
self.live.take().expect("PoolConnection double-dropped").raw
self.live
.take()
.expect("PoolConnection double-dropped")
.float(&self.pool)
.detach()
}
}
@ -154,6 +158,10 @@ impl<'s, DB: Database> Floating<'s, Live<DB>> {
}
}
pub fn detach(self) -> DB::Connection {
self.inner.raw
}
pub fn into_idle(self) -> Floating<'s, Idle<DB>> {
Floating {
inner: self.inner.into_idle(),