Help us shape the future of Go! Take the 2026 Go Developer Survey

ratelimit

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 3 Imported by: 11

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
}

Wrapper around Go's rate.Limiter that supports both global and a per-sender rate limiting.

func NewRateLimiter

func NewRateLimiter(config RateLimiterConfig) (*RateLimiter, error)

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow(sender string) bool

Allow checks that the sender is not rate limited, and that there is not a global rate limit.

func (*RateLimiter) AllowVerbose

func (rl *RateLimiter) AllowVerbose(sender string) (senderAllow bool, globalAllow bool)

Allow checks that the sender is not rate limited, and that there is not a global rate limit. Returns if allowed as separate outputs.

func (*RateLimiter) SetConfig added in v0.9.7

func (rl *RateLimiter) SetConfig(config RateLimiterConfig)

type RateLimiterConfig

type RateLimiterConfig struct {
	GlobalRPS      float64 `json:"globalRPS"`
	GlobalBurst    int     `json:"globalBurst"`
	PerSenderRPS   float64 `json:"perSenderRPS"`
	PerSenderBurst int     `json:"perSenderBurst"`
}

Jump to

Keyboard shortcuts

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