Files
2026-11-28 02:28:13 -08:00

21 lines
621 B
Go

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 }