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 rate.Limit, b int) *IPRateLimiter
創建API限速由IP。
r : 產token的頻率
直接輸入2就代表每秒產2個token 代入此rate.Every(time.Second*3),則代表每三秒產一個token
b : bucket 最多存幾個token。
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.