throttle

package
v0.0.0-...-3f87bd3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPRateLimiter

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

IPRateLimiter .

func NewIPRateLimiter

func NewIPRateLimiter(r time.Duration, b int) *IPRateLimiter

NewIPRateLimiter . 限制每r分钟多少b限制

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 地址添加到映射中

Jump to

Keyboard shortcuts

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