Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPRateLimiter ¶
IPRateLimiter represents a rate limiter based on an IP address.
func NewIPRateLimiter ¶
func NewIPRateLimiter(tps rate.Limit, size int) *IPRateLimiter
NewIPRateLimiter returns a new IPRateLimiter.
func (*IPRateLimiter) AddLimiter ¶
func (ipLimiter *IPRateLimiter) AddLimiter(ipAddr string) *rate.Limiter
AddLimiter creates a new rate limiter and adds it to the limiters map, using the IP address as the key.
func (*IPRateLimiter) GetLimiter ¶
func (ipLimiter *IPRateLimiter) GetLimiter(ipAddr string) *rate.Limiter
GetLimiter returns the rate limiter for the provided IP address if it exists. Otherwise calls AddLimiter to add a new limiter to the map.
type IPWhiteList ¶
type IPWhiteList struct {
// contains filtered or unexported fields
}
IPWhiteList contains white list information for rate limiting.
func NewIPWhiteList ¶
func NewIPWhiteList(ipList []string) (*IPWhiteList, error)
NewIPWhiteList builds a new IPWhiteList from the list of IPs.
Click to show internal directories.
Click to hide internal directories.