|
@@ -5,6 +5,8 @@ import (
|
|
|
"sort"
|
|
"sort"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
+
|
|
|
|
|
+ "github.com/QuantumNous/new-api/types"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type StatusCodeRange struct {
|
|
type StatusCodeRange struct {
|
|
@@ -31,6 +33,10 @@ var alwaysSkipRetryStatusCodes = map[int]struct{}{
|
|
|
524: {},
|
|
524: {},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+var alwaysSkipRetryCodes = map[types.ErrorCode]struct{}{
|
|
|
|
|
+ types.ErrorCodeBadResponseBody: {},
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func AutomaticDisableStatusCodesToString() string {
|
|
func AutomaticDisableStatusCodesToString() string {
|
|
|
return statusCodeRangesToString(AutomaticDisableStatusCodeRanges)
|
|
return statusCodeRangesToString(AutomaticDisableStatusCodeRanges)
|
|
|
}
|
|
}
|
|
@@ -66,6 +72,11 @@ func IsAlwaysSkipRetryStatusCode(code int) bool {
|
|
|
return exists
|
|
return exists
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func IsAlwaysSkipRetryCode(errorCode types.ErrorCode) bool {
|
|
|
|
|
+ _, exists := alwaysSkipRetryCodes[errorCode]
|
|
|
|
|
+ return exists
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func ShouldRetryByStatusCode(code int) bool {
|
|
func ShouldRetryByStatusCode(code int) bool {
|
|
|
if IsAlwaysSkipRetryStatusCode(code) {
|
|
if IsAlwaysSkipRetryStatusCode(code) {
|
|
|
return false
|
|
return false
|