Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientLimiter ¶ added in v4.2.0
type HPClientLimiter ¶ added in v4.2.0
type HPClientLimiter struct {
// contains filtered or unexported fields
}
HPClientLimiter is a ClientLimiter for heavy workload. It uses sharded locks.
func NewHPClientLimiter ¶ added in v4.2.0
func NewHPClientLimiter(opts HPLimiterOpts) (*HPClientLimiter, error)
func (*HPClientLimiter) AcquireToken ¶ added in v4.3.0
func (l *HPClientLimiter) AcquireToken(addr netip.Addr) bool
func (*HPClientLimiter) ApplyMask ¶ added in v4.3.0
func (l *HPClientLimiter) ApplyMask(addr netip.Addr) netip.Prefix
ApplyMask masks the addr by the mask values in HPLimiterOpts.
func (*HPClientLimiter) Close ¶ added in v4.3.0
func (l *HPClientLimiter) Close() error
Close closes HPClientLimiter's cleaner (if it was started). Close always returns a nil error.
func (*HPClientLimiter) GC ¶ added in v4.2.0
func (l *HPClientLimiter) GC(now time.Time)
GC removes expired client ip entries from this HPClientLimiter.
type HPLimiterOpts ¶ added in v4.3.0
type HPLimiterOpts struct { // The rate limit is calculated by Threshold / Interval. // Threshold cannot be negative. Threshold int Interval time.Duration // Default is 1s. // IP masks to aggregate a IP range. IPv4Mask int // Default is 32. IPv6Mask int // Default is 48. // Default is 10s. Negative value disables the cleaner. CleanerInterval time.Duration }
func (*HPLimiterOpts) Init ¶ added in v4.3.0
func (opts *HPLimiterOpts) Init() error
Click to show internal directories.
Click to hide internal directories.