Documentation ¶
Index ¶
Constants ¶
View Source
const (
DefaultRate = 2147483647
)
View Source
const (
RATELIMITER = "RATELIMITER"
)
Variables ¶
View Source
var ( ErrLimiterRegisterAdapterNil = fmt.Errorf("Limiter: Register adapter is nil") ErrLimiterDoubleRegisterAdapter = fmt.Errorf("Limiter: Register called twice for adapter") )
Functions ¶
func HasRegister ¶
Types ¶
type Instance ¶
type Instance func() Limiter
func GetDefaultLimiter ¶
func GetDefaultLimiter() Instance
func GetLimiter ¶
type Limiter ¶
type Limiter interface { TryAccept(name string, qps, burst int) bool // Accept请求, limiter接受正常返回,不接受返回false UpdateRateLimit(name string, qps, burst int) // 更新qps, 并发burst接口,etcd配置变化 DeleteRateLimiter(name string) // 清理 limiter // contains filtered or unexported methods }
func NewRateLimiters ¶
func NewRateLimiters() Limiter
type RateLimiters ¶
func (*RateLimiters) DeleteRateLimiter ¶
func (l *RateLimiters) DeleteRateLimiter(name string)
func (*RateLimiters) UpdateRateLimit ¶
func (l *RateLimiters) UpdateRateLimit(name string, qps, burst int)
Click to show internal directories.
Click to hide internal directories.