Files
renjue 76ba500417
CI / docker (push) Successful in 2m4s
Initial commit: Luminary AI Gateway
OpenAI-compatible AI gateway with Vue admin UI, multi-provider egress,
ingress key governance, monitoring, and security controls.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 21:46:16 +08:00

44 lines
1.0 KiB
Go

package gateway
import "net/http"
// retryableUpstreamStatus reports HTTP codes that should trigger retry / failover.
func retryableUpstreamStatus(code int) bool {
switch code {
case http.StatusTooManyRequests,
http.StatusRequestTimeout,
http.StatusBadGateway,
http.StatusServiceUnavailable,
http.StatusGatewayTimeout:
return true
default:
return code >= 500
}
}
// tryNextKeyOnUpstreamStatus reports auth/rate errors where another provider key may work.
func tryNextKeyOnUpstreamStatus(code int) bool {
switch code {
case http.StatusUnauthorized,
http.StatusForbidden,
http.StatusTooManyRequests,
http.StatusPaymentRequired:
return true
default:
return retryableUpstreamStatus(code)
}
}
// passThroughUpstreamStatus reports client errors that should be returned as-is.
func passThroughUpstreamStatus(code int) bool {
switch code {
case http.StatusBadRequest,
http.StatusNotFound,
http.StatusUnprocessableEntity,
http.StatusUnsupportedMediaType:
return true
default:
return false
}
}