@@ -10,6 +10,7 @@ import (
10
10
"github.com/deploymenttheory/go-api-http-client/authenticationhandler"
11
11
"github.com/deploymenttheory/go-api-http-client/headers"
12
12
"github.com/deploymenttheory/go-api-http-client/logger"
13
+ "github.com/deploymenttheory/go-api-http-client/ratehandler"
13
14
"github.com/deploymenttheory/go-api-http-client/status"
14
15
"github.com/google/uuid"
15
16
"go.uber.org/zap"
@@ -207,7 +208,7 @@ func (c *Client) executeRequestWithRetries(method, endpoint string, body, out in
207
208
208
209
// Parsing rate limit headers if a rate-limit error is detected
209
210
if status .IsRateLimitError (resp ) {
210
- waitDuration := parseRateLimitHeaders (resp , log )
211
+ waitDuration := ratehandler . ParseRateLimitHeaders (resp , log )
211
212
if waitDuration > 0 {
212
213
log .Warn ("Rate limit encountered, waiting before retrying" , zap .Duration ("waitDuration" , waitDuration ))
213
214
time .Sleep (waitDuration )
@@ -222,7 +223,7 @@ func (c *Client) executeRequestWithRetries(method, endpoint string, body, out in
222
223
log .Warn ("Max retry attempts reached" , zap .String ("method" , method ), zap .String ("endpoint" , endpoint ))
223
224
break // Stop retrying if max attempts are reached
224
225
}
225
- waitDuration := calculateBackoff (retryCount )
226
+ waitDuration := ratehandler . CalculateBackoff (retryCount )
226
227
log .Warn ("Retrying request due to transient error" , zap .String ("method" , method ), zap .String ("endpoint" , endpoint ), zap .Int ("retryCount" , retryCount ), zap .Duration ("waitDuration" , waitDuration ), zap .Error (err ))
227
228
time .Sleep (waitDuration ) // Wait before retrying
228
229
continue // Continue to next iteration after waiting
0 commit comments