rate

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	GlobalLimitKey = "$"
	IPLimitKey     = "$$"
)

Variables

View Source
var (
	ErrRateLimit = errors.New("rate limit")
)

Functions

func NewLimiter

func NewLimiter(r float64, b int) limiter.Limiter

func NewRateLimiter

func NewRateLimiter(opts ...Option) limiter.RateLimiter

Types

type Option

type Option func(opts *options)

func FileLoaderOption

func FileLoaderOption(fileLoader loader.Loader) Option

func HTTPLoaderOption

func HTTPLoaderOption(httpLoader loader.Loader) Option

func LimitsOption

func LimitsOption(limits ...string) Option

func LoggerOption

func LoggerOption(logger logger.Logger) Option

func RedisLoaderOption

func RedisLoaderOption(redisLoader loader.Loader) Option

func ReloadPeriodOption

func ReloadPeriodOption(period time.Duration) Option

type RateLimitGenerator

type RateLimitGenerator interface {
	Limiter() limiter.Limiter
}

func NewRateLimitGenerator

func NewRateLimitGenerator(r float64) RateLimitGenerator

func NewRateLimitSingleGenerator

func NewRateLimitSingleGenerator(r float64) RateLimitGenerator

Jump to

Keyboard shortcuts

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