ratelimiter

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 4 Imported by: 0

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 manages rate limiters for different IPs with eviction support.

func NewIPRateLimiter

func NewIPRateLimiter(r rate.Limit, b int, t itimeservice.IService) *IPRateLimiter

NewIPRateLimiter initializes a new IPRateLimiter with the given rate and burst size.

func (*IPRateLimiter) AddLimiter

func (i *IPRateLimiter) AddLimiter(ip string) *rate.Limiter

AddLimiter creates a new rate limiter for the provided IP and adds it to the map.

func (*IPRateLimiter) GetLimiter

func (i *IPRateLimiter) GetLimiter(ip string) *rate.Limiter

GetLimiter retrieves the rate limiter for the provided IP. If it doesn't exist, a new one is created.

type IRateLimiter

type IRateLimiter interface {
	AddLimiter(ip string) *rate.Limiter
	GetLimiter(ip string) *rate.Limiter
}

type LimiterEntry

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

LimiterEntry contains the rate limiter and the last time it was accessed.

Jump to

Keyboard shortcuts

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