ratelimiter

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

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

RateLimiter implements a token bucket rate limiter

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow() bool

type UserRateLimiter

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

UserRateLimiter manages rate limiting for multiple users

func New

func New(rate float64, capacity float64, expirationTime time.Duration) *UserRateLimiter

NewUserRateLimiter creates a new UserRateLimiter instance

func OncePerMinute

func OncePerMinute() *UserRateLimiter

func OncePerSecond

func OncePerSecond() *UserRateLimiter

func Rps10

func Rps10() *UserRateLimiter

func Rps100

func Rps100() *UserRateLimiter

func Rps1000

func Rps1000() *UserRateLimiter

func (*UserRateLimiter) Allow

func (url *UserRateLimiter) Allow(userID string) bool

Allow checks if a request should be allowed for a given user

func (*UserRateLimiter) Stop

func (url *UserRateLimiter) Stop()

Stop cleans up all timers

Jump to

Keyboard shortcuts

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