refactor(netx/resolver): add CloseIdleConnections to RoundTripper (#501)
While there, also change to pointer receiver and use internal testing for what are clearly unit tests. Part of https://github.com/ooni/probe/issues/1591.
This commit is contained in:
parent
5ab3c3b689
commit
1eb9e8c9b0
13 changed files with 203 additions and 115 deletions
|
|
@ -22,6 +22,9 @@ type RoundTripper interface {
|
|||
|
||||
// Address is the address of the round tripper (e.g. "1.1.1.1:853")
|
||||
Address() string
|
||||
|
||||
// CloseIdleConnections closes idle connections.
|
||||
CloseIdleConnections()
|
||||
}
|
||||
|
||||
// SerialResolver is a resolver that first issues an A query and then
|
||||
|
|
@ -81,7 +84,7 @@ func (r SerialResolver) roundTripWithRetry(
|
|||
}
|
||||
errorslist = append(errorslist, err)
|
||||
var operr *net.OpError
|
||||
if errors.As(err, &operr) == false || operr.Timeout() == false {
|
||||
if !errors.As(err, &operr) || !operr.Timeout() {
|
||||
// The first error is the one that is most likely to be caused
|
||||
// by the network. Subsequent errors are more likely to be caused
|
||||
// by context deadlines. So, the first error is attached to an
|
||||
|
|
|
|||
Loading…
Reference in a new issue