shouldRetryDial reports whether the current request should retry dialing after the call finished unsuccessfully, for example if the dial was canceled because of a context cancellation or deadline expiry.
(call *dialCall, req *http.Request)
| 260 | // if the dial was canceled because of a context cancellation or |
| 261 | // deadline expiry. |
| 262 | func shouldRetryDial(call *dialCall, req *http.Request) bool { |
| 263 | if call.err == nil { |
| 264 | // No error, no need to retry |
| 265 | return false |
| 266 | } |
| 267 | if call.ctx == req.Context() { |
| 268 | // If the call has the same context as the request, the dial |
| 269 | // should not be retried, since any cancellation will have come |
| 270 | // from this request. |
| 271 | return false |
| 272 | } |
| 273 | if !errors.Is(call.err, context.Canceled) && !errors.Is(call.err, context.DeadlineExceeded) { |
| 274 | // If the call error is not because of a context cancellation or a deadline expiry, |
| 275 | // the dial should not be retried. |
| 276 | return false |
| 277 | } |
| 278 | // Only retry if the error is a context cancellation error or deadline expiry |
| 279 | // and the context associated with the call was canceled or expired. |
| 280 | return call.ctx.Err() != nil |
| 281 | } |
no test coverage detected
searching dependent graphs…