Merge pull request #464 from touwaeriol/pr/antigravity-scope-ratelimit

feat(antigravity): 支持按配额域(scope)级别限流
This commit is contained in:
Wesley Liddick
2026-02-03 15:02:15 +08:00
committed by GitHub
13 changed files with 229 additions and 26 deletions

View File

@@ -1537,7 +1537,11 @@ func sleepAntigravityBackoffWithContext(ctx context.Context, attempt int) bool {
func antigravityUseScopeRateLimit() bool {
v := strings.ToLower(strings.TrimSpace(os.Getenv(antigravityScopeRateLimitEnv)))
return v == "1" || v == "true" || v == "yes" || v == "on"
// 默认开启按配额域限流,只有明确设置为禁用值时才关闭
if v == "0" || v == "false" || v == "no" || v == "off" {
return false
}
return true
}
func (s *AntigravityGatewayService) handleUpstreamError(ctx context.Context, prefix string, account *Account, statusCode int, headers http.Header, body []byte, quotaScope AntigravityQuotaScope) {