Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FixedWindowLimiter ¶
type FixedWindowLimiter struct {
// contains filtered or unexported fields
}
FixedWindowLimiter implements fixed window counter algorithm.
func NewFixedWindowLimiter ¶
func NewFixedWindowLimiter(limit int, window time.Duration) (*FixedWindowLimiter, error)
func (*FixedWindowLimiter) Allow ¶
func (l *FixedWindowLimiter) Allow(ctx context.Context, key string) (ratelimiter.Decision, error)
func (*FixedWindowLimiter) AllowN ¶
func (l *FixedWindowLimiter) AllowN(_ context.Context, key string, n int) (ratelimiter.Decision, error)
func (*FixedWindowLimiter) ImplName ¶
func (l *FixedWindowLimiter) ImplName() scene.ImplName
type LeakyBucketLimiter ¶
type LeakyBucketLimiter struct {
// contains filtered or unexported fields
}
LeakyBucketLimiter implements leaky bucket algorithm.
func NewLeakyBucketLimiter ¶
func NewLeakyBucketLimiter(limit int, window time.Duration) (*LeakyBucketLimiter, error)
func (*LeakyBucketLimiter) Allow ¶
func (l *LeakyBucketLimiter) Allow(ctx context.Context, key string) (ratelimiter.Decision, error)
func (*LeakyBucketLimiter) AllowN ¶
func (l *LeakyBucketLimiter) AllowN(_ context.Context, key string, n int) (ratelimiter.Decision, error)
func (*LeakyBucketLimiter) ImplName ¶
func (l *LeakyBucketLimiter) ImplName() scene.ImplName
type SlidingWindowCounterLimiter ¶
type SlidingWindowCounterLimiter struct {
// contains filtered or unexported fields
}
SlidingWindowCounterLimiter implements sliding window counter algorithm.
func NewSlidingWindowCounterLimiter ¶
func NewSlidingWindowCounterLimiter(limit int, window time.Duration) (*SlidingWindowCounterLimiter, error)
func (*SlidingWindowCounterLimiter) Allow ¶
func (l *SlidingWindowCounterLimiter) Allow(ctx context.Context, key string) (ratelimiter.Decision, error)
func (*SlidingWindowCounterLimiter) AllowN ¶
func (l *SlidingWindowCounterLimiter) AllowN(_ context.Context, key string, n int) (ratelimiter.Decision, error)
func (*SlidingWindowCounterLimiter) ImplName ¶
func (l *SlidingWindowCounterLimiter) ImplName() scene.ImplName
type SlidingWindowLogLimiter ¶
type SlidingWindowLogLimiter struct {
// contains filtered or unexported fields
}
SlidingWindowLogLimiter implements sliding window log algorithm.
func NewSlidingWindowLogLimiter ¶
func NewSlidingWindowLogLimiter(limit int, window time.Duration) (*SlidingWindowLogLimiter, error)
func (*SlidingWindowLogLimiter) Allow ¶
func (l *SlidingWindowLogLimiter) Allow(ctx context.Context, key string) (ratelimiter.Decision, error)
func (*SlidingWindowLogLimiter) AllowN ¶
func (l *SlidingWindowLogLimiter) AllowN(_ context.Context, key string, n int) (ratelimiter.Decision, error)
func (*SlidingWindowLogLimiter) ImplName ¶
func (l *SlidingWindowLogLimiter) ImplName() scene.ImplName
type TimeRateLimiter ¶
type TimeRateLimiter struct {
// contains filtered or unexported fields
}
TimeRateLimiter wraps golang.org/x/time/rate limiter per key.
func NewTimeRateLimiter ¶
func NewTimeRateLimiter(limit int, window time.Duration) (*TimeRateLimiter, error)
func (*TimeRateLimiter) Allow ¶
func (l *TimeRateLimiter) Allow(ctx context.Context, key string) (ratelimiter.Decision, error)
func (*TimeRateLimiter) AllowN ¶
func (l *TimeRateLimiter) AllowN(_ context.Context, key string, n int) (ratelimiter.Decision, error)
func (*TimeRateLimiter) ImplName ¶
func (l *TimeRateLimiter) ImplName() scene.ImplName
type TokenBucketLimiter ¶
type TokenBucketLimiter struct {
// contains filtered or unexported fields
}
TokenBucketLimiter implements token bucket algorithm.
func NewTokenBucketLimiter ¶
func NewTokenBucketLimiter(limit int, window time.Duration) (*TokenBucketLimiter, error)
func (*TokenBucketLimiter) Allow ¶
func (l *TokenBucketLimiter) Allow(ctx context.Context, key string) (ratelimiter.Decision, error)
func (*TokenBucketLimiter) AllowN ¶
func (l *TokenBucketLimiter) AllowN(_ context.Context, key string, n int) (ratelimiter.Decision, error)
func (*TokenBucketLimiter) ImplName ¶
func (l *TokenBucketLimiter) ImplName() scene.ImplName
Click to show internal directories.
Click to hide internal directories.