You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add new postgres manager builder and support a custom validation query
Issue djc#73 was looking to make a "DISCARD ALL" query possible when a
connection is returned to the pool. Because async drop isn't a thing,
this isn't really possible at the moment. However, we can use the
`is_valid` method on the `ManagedConnection` trait to discard all
session state before yielding the connection.
This PR makes it possible to change the query used within the `is_valid`
method call in `bb8_postgres`.
To make configuring the validation query a little easier, I added a new
postgres connection manager builder helper type. Let me know if you're
:+1: or :-1: on that.
This also includes an example called buidler.rs that shows how someone
could use `DISCARD ALL` as a validation query. It then prints a few
things to show that session state was indeed cleared between checkouts.
```
$ cargo run --example builder
...
The current connection PID: 86445
BB8 says, "beep boop"
The current connection PID: 86445
After DISCARD ALL on checkout, BB8 says, ""
```
0 commit comments