Hi I created an implementation of vibe's connectionpool with my postgtres lib. Now I'd like to log the output to show when a connection is opened, locked and when it's unlocked (which should be at the end of a route callback call.
Looking at the source, I don't see a clear way to create a callback on unlocking a connection and I'd like to make sure the connection unlocks if a http connection is cancelled or abandoned.
So, for example, I have this(just sample code, not actual D):
static this() {
PgPool pool = new PgPool(connParams);
... routes defined here
}
void getUser(req, res) {
auto db = pool.lock()
db.query(...)
req.writeBody...
}
What happens when getUser is called but the request is cancelled halfway through before the query finishes?
Is there ever a time when the lock will never be released?
I'd like to create log output to say "pg unlock: 4 locked connections, 10 open connections in pool"