fix: 上行分发前统一限速,send 不再单独扣桶

This commit is contained in:
Nixevol
2026-09-30 16:21:05 +08:00
parent f139b9ed9b
commit aa24e974af
7 changed files with 155 additions and 13 deletions
+8
View File
@@ -57,3 +57,11 @@ func (r *rateLimiter) allow(endpointID string, now time.Time) bool {
b.tokens--
return true
}
// AllowRequest 消耗该端 1 个请求令牌;允许则 true。rps<=0 时不限速。
func (a *App) AllowRequest(endpointID string) bool {
if a == nil {
return true
}
return a.rates.allow(endpointID, a.now())
}