ratelimit

package
v0.0.0-...-4d64e5c Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enable    bool     `json:"enable"`
	Burst     int      `json:"burst"`
	Rate      int      `json:"rate"`
	WhiteList []string `json:"whitelist"`
	BlackList []string `json:"blacklist"`
}

type Limiter

type Limiter struct {
	Size       time.Duration
	LastUpdate time.Time
	Mutex      *sync.Mutex
}

type RateLimiter

type RateLimiter struct {
	Limiters  *cache.Cache
	MaxTime   time.Duration
	TimeStep  time.Duration
	Config    *Config
	WhiteList map[string]interface{}
	BlackList map[string]interface{}
}

func NewRateLimiter

func NewRateLimiter(config *Config) *RateLimiter

func (*RateLimiter) CanHandle

func (rl *RateLimiter) CanHandle(key string) bool

Jump to

Keyboard shortcuts

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