limiter

package
v0.0.0-...-264f9d0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientLimiter

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

func NewClientLimiter

func NewClientLimiter(opts ClientLimiterOpts) *ClientLimiter

Creates a ClientLimiter. Note: Call ClientLimiter.Close() to stop its gc goroutine.

func (*ClientLimiter) AllowN

func (cl *ClientLimiter) AllowN(addr netip.Addr, now time.Time, n int) bool

func (*ClientLimiter) Close

func (cl *ClientLimiter) Close() error

Stop gc goroutine. Do not use this limiter once it was closed. Always return nil.

type ClientLimiterOpts

type ClientLimiterOpts struct {
	Limit  float64 // default 20
	Burst  int     // default is Qps
	V4Mask int     // default 24
	V6Mask int     // default 48
}

Jump to

Keyboard shortcuts

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