This commit is contained in:
1 parent
624093773b
commit
568e516b1a
18 files changed
+912
-80
No files matched your search
@@ -0,0 +1,20 @@
|
||||
package ratelimit
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Disabled 表示入口明确禁用流控时的无状态实现。
|
||||
type Disabled struct{}
|
||||
|
||||
// AllowN 在关闭流控时始终放行。
|
||||
// 入参:ctx 为调用上下文,cfg 为额度配置,count 为消耗令牌数。
|
||||
// 返回:固定允许且无错误。
|
||||
func (Disabled) AllowN(ctx context.Context, cfg *Config, count int) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Reset 在关闭流控时无需清理状态。
|
||||
// 入参:ctx 为调用上下文,cfg 为主体配置。
|
||||
// 返回:固定 nil。
|
||||
func (Disabled) Reset(ctx context.Context, cfg *Config) error { return nil }
|
||||