fix: address code review findings

This commit is contained in:
2026-08-17 21:50:37 +03:00
parent 9c402c0086
commit 777fda95a3
6 changed files with 76 additions and 23 deletions

View File

@@ -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.