(statusCode int, errorText string, cfg RetryConfig)
| 239 | for attempt := 0; attempt <= cfg.MaxRetries; attempt++ { |
| 240 | if !waitProviderCooldown(ctx, cooldownKey) { |
| 241 | return nil, ctx.Err() |
| 242 | } |
| 243 | reqCtx, cancel := context.WithTimeout(ctx, timeout) |
| 244 | resp, err := makeRequest(reqCtx, c.HTTPClient) |
| 245 | |
| 246 | if err != nil { |
| 247 | cancel() |
| 248 | lastErr = err |
| 249 | if attempt < cfg.MaxRetries { |
| 250 | if !sleepBackoff(ctx, attempt, cfg) { |
| 251 | return nil, ctx.Err() |
| 252 | } |
| 253 | continue |
| 254 | } |
| 255 | break |
| 256 | } |
| 257 | |
| 258 | if resp == nil { |
| 259 | cancel() |