fix: 上行分发前统一限速,send 不再单独扣桶
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user