ratelimit

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiters

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

Limiters provides map of rate limiters per X (user, IP..).

func NewLimiter

func NewLimiter(r rate.Limit, burst int) *Limiters

func (*Limiters) Add

func (l *Limiters) Add(key string) *rate.Limiter

Add creates a new rate limiter and adds it to the map.

func (*Limiters) Allow

func (l *Limiters) Allow(key string) bool

func (*Limiters) Get

func (l *Limiters) Get(key string) *rate.Limiter

Get returns the rate limiter for the provided key if it exists, otherwise calls Add to add key to the map.

Jump to

Keyboard shortcuts

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