fix: address code review findings
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -269,8 +270,17 @@ func isRetryableError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
// Network-level errors are retryable
|
||||
return true
|
||||
// Check for HTTP status codes that are retryable (5xx errors)
|
||||
apiErr, ok := err.(*APIError)
|
||||
if ok {
|
||||
return apiErr.Code >= 500 && apiErr.Code < 600
|
||||
}
|
||||
// Check for network errors
|
||||
errStr := err.Error()
|
||||
return strings.Contains(errStr, "timeout") ||
|
||||
strings.Contains(errStr, "connection refused") ||
|
||||
strings.Contains(errStr, "dial tcp") ||
|
||||
strings.Contains(errStr, "context deadline exceeded")
|
||||
}
|
||||
|
||||
// buildURL constructs a Yandex API URL with query parameters.
|
||||
|
||||
Reference in New Issue
Block a user