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 地址添加到映射中
Click to show internal directories.
Click to hide internal directories.