limit

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Limiter

func Limiter() gin.HandlerFunc

func SetUp

func SetUp(options ...Option)

Types

type Config

type Config struct {
	Rate     int
	Bursts   int
	WaitTime int
}

type IPRateLimiter

type IPRateLimiter struct {
	// contains filtered or unexported fields
}

IPRateLimiter .

func GetIPRateLimiter

func GetIPRateLimiter() *IPRateLimiter

func NewIPRateLimiter

func NewIPRateLimiter() *IPRateLimiter

NewIPRateLimiter .

func (*IPRateLimiter) AddIP

func (i *IPRateLimiter) AddIP(ip string) *rate.Limiter

AddIP 创建了一个新的速率限制器,并将其添加到 ips 映射中, 使用 IP地址作为密钥

func (*IPRateLimiter) GetLimiter

func (i *IPRateLimiter) GetLimiter(ip string) *rate.Limiter

GetLimiter 返回所提供的IP地址的速率限制器(如果存在的话). 否则调用 AddIP 将 IP 地址添加到映射中

type Option

type Option func(c *Config)

func Bursts

func Bursts(bursts int) Option

func Rate

func Rate(rate int) Option

func WaitTime

func WaitTime(waitTime int) Option

Jump to

Keyboard shortcuts

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