-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
In pool.go, ConnectionClosed events are published in the expiration-checking function and in disconnect for forcefully-closed connections. This doesn't cover all cases though, because connections closed gracefully during disconnect don't go through the expiration checker and connections that encounter network errors manually call pool.removeConnnection on themselves. We can move the event-firing to closeConnection and removeConnection because all cases go through one of those. We'll have to store the reason for closing (e.g. idle, pool closing, etc) on the connection so the event can be published correctly.
The timer variable in pool.disconnect is incorrect. It calculates the time to fire as now-contextDeadline, which will be negative if the deadline is in the future. I don't know why that timer is there at all. I think the ctx.Done() + ticker cases cover everything we need.