ratelimits

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: LGPL-3.0 Imports: 4 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 {
	RequestsPerSecond    rate.Limit
	SecondsBurstCapacity int
	RequestsPerMinute    rate.Limit
	MinutesBurstCapacity int
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter(reqPerMin rate.Limit, minBurst int) *RateLimiter

NewRateLimiter initializes a new RateLimiter with per-minute ratings

func (*RateLimiter) CanHandle

func (rl *RateLimiter) CanHandle(identifier string) bool

CanHandleRequest checks if the rate limiters allow another request based on both per-second and per-minute limits.

func (*RateLimiter) WithSecondsLimits

func (rl *RateLimiter) WithSecondsLimits(reqPerSec rate.Limit, secBurst int) *RateLimiter

Jump to

Keyboard shortcuts

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