The http2 Transport exposes a CloseIdleConnections method that will call the method of the same name on the ClientConnPool if it implements the private clientConnPoolIdleCloser interface. The ClientConnPool implementation calls the private method closeIfIdle on each pooled ClientConn.
If one want to create a custom ClientConnPool, there is no way to make this custom pool support this feature without exposing CloseIfIdle method and ClientConnPoolIdleCloser interface.
The text was updated successfully, but these errors were encountered:
We are implementing our own ClientConnPool. One feature of the default pool is its ability to trigger the closing of idle connections. To do that, it exposes a private interface clientConnPoolIdleCloser consisting of the method closeIdleConnections. When this interface is implemented, the transport call this method if CloseIdleConnections is called. First problem, there is no way for a custom pool to replicate this behavior.
But we could have our pool handling idle connections by itself, without relying on this Transport. CloseIdleConnections (that's what we do). But then, we miss another method used by the clientConnPool.closeIdleConnections method which is closeIfIdle on ClientConn.
This seems entirely reasonable. http2.Transport.CloseIdleConnections() is a no-op when the transport uses a custom ClientConnPool. This is a definite wart. I don't see a better way to do this other than exporting ClientConn.CloseIfIdle.