fix(rate-limit): remove 429 cooldown config option
This commit is contained in:
parent
37f7c7128c
commit
11ae6f2105
@ -1117,9 +1117,8 @@ type DefaultConfig struct {
|
||||
}
|
||||
|
||||
type RateLimitConfig struct {
|
||||
OverloadCooldownMinutes int `mapstructure:"overload_cooldown_minutes"` // 529过载冷却时间(分钟)
|
||||
RateLimit429CooldownSeconds int `mapstructure:"rate_limit_429_cooldown_seconds"` // 429无重置时间时的默认回避时间(秒)
|
||||
OAuth401CooldownMinutes int `mapstructure:"oauth_401_cooldown_minutes"` // OAuth 401临时不可调度冷却(分钟)
|
||||
OverloadCooldownMinutes int `mapstructure:"overload_cooldown_minutes"` // 529过载冷却时间(分钟)
|
||||
OAuth401CooldownMinutes int `mapstructure:"oauth_401_cooldown_minutes"` // OAuth 401临时不可调度冷却(分钟)
|
||||
}
|
||||
|
||||
// APIKeyAuthCacheConfig API Key 认证缓存配置
|
||||
@ -1579,7 +1578,6 @@ func setDefaults() {
|
||||
|
||||
// RateLimit
|
||||
viper.SetDefault("rate_limit.overload_cooldown_minutes", 10)
|
||||
viper.SetDefault("rate_limit.rate_limit_429_cooldown_seconds", 5)
|
||||
viper.SetDefault("rate_limit.oauth_401_cooldown_minutes", 10)
|
||||
|
||||
// Pricing - 从 model-price-repo 同步模型定价和上下文窗口数据(固定到 commit,避免分支漂移)
|
||||
|
||||
@ -97,10 +97,9 @@ func TestHandle429_FallbackDisabledSkipsLocalMark(t *testing.T) {
|
||||
require.Zero(t, accountRepo.rateLimitCalls)
|
||||
}
|
||||
|
||||
func TestHandle429_FallbackUsesConfigSecondsWhenSettingServiceMissing(t *testing.T) {
|
||||
func TestHandle429_FallbackUsesDefaultSecondsWhenSettingServiceMissing(t *testing.T) {
|
||||
accountRepo := &rateLimit429AccountRepoStub{}
|
||||
cfg := &config.Config{}
|
||||
cfg.RateLimit.RateLimit429CooldownSeconds = 9
|
||||
svc := NewRateLimitService(accountRepo, nil, cfg, nil, nil)
|
||||
|
||||
account := &Account{ID: 44, Platform: PlatformGemini, Type: AccountTypeAPIKey}
|
||||
@ -110,5 +109,5 @@ func TestHandle429_FallbackUsesConfigSecondsWhenSettingServiceMissing(t *testing
|
||||
|
||||
require.Equal(t, 1, accountRepo.rateLimitCalls)
|
||||
require.Equal(t, int64(44), accountRepo.lastRateLimitID)
|
||||
require.True(t, !accountRepo.lastRateLimitReset.Before(before.Add(9*time.Second)) && !accountRepo.lastRateLimitReset.After(after.Add(9*time.Second)))
|
||||
require.True(t, !accountRepo.lastRateLimitReset.Before(before.Add(5*time.Second)) && !accountRepo.lastRateLimitReset.After(after.Add(5*time.Second)))
|
||||
}
|
||||
|
||||
@ -955,9 +955,6 @@ func (s *RateLimitService) get429FallbackCooldown(ctx context.Context, account *
|
||||
}
|
||||
|
||||
seconds := defaultRateLimit429CooldownSeconds
|
||||
if s.cfg != nil && s.cfg.RateLimit.RateLimit429CooldownSeconds > 0 {
|
||||
seconds = s.cfg.RateLimit.RateLimit429CooldownSeconds
|
||||
}
|
||||
seconds = clampRateLimit429CooldownSeconds(seconds)
|
||||
return time.Duration(seconds) * time.Second, true
|
||||
}
|
||||
|
||||
@ -948,10 +948,6 @@ rate_limit:
|
||||
# 上游返回 529(过载)时的冷却时间(分钟)
|
||||
overload_cooldown_minutes: 10
|
||||
|
||||
# Default cooldown time (in seconds) when upstream returns 429 without a reset time
|
||||
# 上游返回 429 且无明确重置时间时的默认回避时间(秒)
|
||||
rate_limit_429_cooldown_seconds: 5
|
||||
|
||||
# =============================================================================
|
||||
# Pricing Data Source (Optional)
|
||||
# 定价数据源(可选)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user