shouldRetry determines if a request should be retried.
(err error, attempt, maxRetries int)
| 212 | |
| 213 | // shouldRetry determines if a request should be retried. |
| 214 | func (hc *HTTPClient) shouldRetry(err error, attempt, maxRetries int) bool { |
| 215 | if attempt >= maxRetries { |
| 216 | return false |
| 217 | } |
| 218 | |
| 219 | // Retry on network errors, timeouts, and 5xx server errors |
| 220 | if strings.Contains(err.Error(), "connection") || |
| 221 | strings.Contains(err.Error(), "timeout") || |
| 222 | strings.Contains(err.Error(), "status 5") { |
| 223 | return true |
| 224 | } |
| 225 | |
| 226 | return false |
| 227 | } |