limit

package
v0.0.0-...-326f463 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPBasedRateLimiter

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

func NewIPBasedRateLimiter

func NewIPBasedRateLimiter(limit int, window time.Duration, window2 string) *IPBasedRateLimiter

func (*IPBasedRateLimiter) Allow

func (iprl *IPBasedRateLimiter) Allow(ip string, pass bool, count int) IsAllow

pass: true means only check, false means check and add request

count: if pass is false, count is the number of requests to add

type IPBasedRateLimiters

type IPBasedRateLimiters []*IPBasedRateLimiter
var (
	Limits IPBasedRateLimiters
)

func (IPBasedRateLimiters) AllowPassCheck

func (iprls IPBasedRateLimiters) AllowPassCheck(ip string)

func (IPBasedRateLimiters) LoadFromCache

func (iprls IPBasedRateLimiters) LoadFromCache() error

func (IPBasedRateLimiters) Prune

func (iprls IPBasedRateLimiters) Prune(ip string)

func (IPBasedRateLimiters) SaveCache

func (iprls IPBasedRateLimiters) SaveCache() error

type IsAllow

type IsAllow struct {
	Allow bool
	Used  int
	Limit int
	Wind  string
}

type SlidingWindowRateLimiter

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

func NewSlidingWindowRateLimiter

func NewSlidingWindowRateLimiter(limit int, window time.Duration, window2 string) *SlidingWindowRateLimiter

func (*SlidingWindowRateLimiter) Allow

func (rl *SlidingWindowRateLimiter) Allow(pass bool, count int) IsAllow

Jump to

Keyboard shortcuts

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