(tripper http.RoundTripper)
| 83 | } |
| 84 | |
| 85 | func retryableErrorTransport(tripper http.RoundTripper) http.RoundTripper { |
| 86 | retryableCodes := []int{ |
| 87 | http.StatusServiceUnavailable, |
| 88 | http.StatusInternalServerError, |
| 89 | http.StatusBadGateway, |
| 90 | http.StatusGatewayTimeout, |
| 91 | // Cloudflare-specific server error that is generated |
| 92 | // because Cloudflare did not receive an HTTP response |
| 93 | // from the origin server after an HTTP Connection was made. |
| 94 | 524, |
| 95 | } |
| 96 | |
| 97 | return rehttp.NewTransport( |
| 98 | tripper, |
| 99 | rehttp.RetryAll( |
| 100 | rehttp.RetryMaxRetries(3), |
| 101 | rehttp.RetryAny( |
| 102 | rehttp.RetryStatuses(retryableCodes...), |
| 103 | rehttp.RetryIsErr(retryableErrorRetryFunc), |
| 104 | ), |
| 105 | ), |
| 106 | rehttp.ExpJitterDelay(500*time.Millisecond, 10*time.Second), |
| 107 | ) |
| 108 | } |
| 109 | |
| 110 | func retryableErrorRetryFunc(err error) bool { |
| 111 | if err == nil { |
no outgoing calls
no test coverage detected