Documentation ¶
Index ¶
- type Limiter
- func NewFixedWindowLimiter(limit int, window time.Duration) Limiter
- func NewLeakyBucketLimiter(peakLevel, currentVelocity int) Limiter
- func NewSlidingLogLimiter(smallWindow time.Duration, strategies ...*SlidingLogLimiterStrategy) (Limiter, error)
- func NewSlidingWindowLimiter(limit int, window, smallWindow time.Duration) (Limiter, error)
- func NewTokenBucketLimiter(capacity, rate int) Limiter
- type RedisLimiter
- type SlidingLogLimiterStrategy
- type ViolationStrategyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter interface {
TryAcquire() error
}
func NewLeakyBucketLimiter ¶
func NewSlidingLogLimiter ¶
func NewSlidingLogLimiter(smallWindow time.Duration, strategies ...*SlidingLogLimiterStrategy) (Limiter, error)
func NewSlidingWindowLimiter ¶
func NewTokenBucketLimiter ¶
type RedisLimiter ¶
type SlidingLogLimiterStrategy ¶
type SlidingLogLimiterStrategy struct {
// contains filtered or unexported fields
}
SlidingLogLimiterStrategy 滑动日志限流器的策略
func NewSlidingLogLimiterStrategy ¶
func NewSlidingLogLimiterStrategy(limit int, window time.Duration) *SlidingLogLimiterStrategy
type ViolationStrategyError ¶
ViolationStrategyError 违背策略错误
func (*ViolationStrategyError) Error ¶
func (e *ViolationStrategyError) Error() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.