slidingwindow

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLimiter

type DefaultLimiter struct {
	RedisClient redis.Cmdable
}

DefaultLimiter implements Sliding-Windows-Log rate limiter algorithm

func (*DefaultLimiter) ShouldAllow

func (l *DefaultLimiter) ShouldAllow(ctx context.Context, key string, size time.Duration, limit int64) (allow bool, err error)

ShouldAllow returns if current request is allowed or not.

type RateLimiter

type RateLimiter interface {
	ShouldAllow(ctx context.Context, key string, size time.Duration, limit int64) (allow bool, err error)
}

func NewDefaultLimiter

func NewDefaultLimiter(redisClient redis.Cmdable) RateLimiter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL