ratelimit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 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 Limiter

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

Limiter implements a simple token bucket rate limiter backed by KVS

func NewLimiter

func NewLimiter(rate int, interval time.Duration, kvsStore kvs.Store) *Limiter

NewLimiter creates a new rate limiter backed by KVS rate: number of allowed requests interval: time window for the rate

func (*Limiter) Allow

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

Allow checks if a request is allowed for the given key

func (*Limiter) Cleanup

func (l *Limiter) Cleanup(maxAge time.Duration)

Cleanup removes old buckets that haven't been used recently

func (*Limiter) Reset

func (l *Limiter) Reset(key string)

Reset clears the rate limit for a specific key

Jump to

Keyboard shortcuts

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