sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.49k stars 80 forks source link

Pass additional data to event handler #107

Open Diggsey opened 4 years ago

Diggsey commented 4 years ago

I've found the event handler mechanism extremely useful (particularly the Checkin event) but it would be useful to be able to pass additional information when obtaining a connection from the pool to then be accessible to the event handler.

In my case this additional information would be a "transaction name" - so that if our event handler does observe a slow transaction, we can easily observe which transaction was the cause. There are a couple of options I can think of:

The former has the advantage that the transaction name could be available to checkout and checkin events, while the latter would only work for checkin events. However, checkin is more important.

sunng87 commented 2 years ago

CustomizeConnection seems to work for this scenario too. However, it does not has access to Extension either.