limiter

package
v0.2.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxExactInteger int64 = 1<<53 - 1

MaxExactInteger is the largest integer that the Redis Lua runtime can represent exactly. Limiter configuration values must stay within this boundary because Redis executes Lua numbers as IEEE-754 doubles.

Variables

This section is empty.

Functions

func ValidateConfig

func ValidateConfig(config Config) error

ValidateConfig verifies that a limiter configuration can be passed to the Redis Lua runtime without changing its integer values.

Types

type Config

type Config struct {
	Capacity  int64
	Rate      int64
	Requested int64
}

Config 配置选项模式

type Option

type Option func(*Config)

func WithCapacity

func WithCapacity(c int64) Option

func WithRate

func WithRate(r int64) Option

func WithRequested

func WithRequested(n int64) Option

type RedisLimiter

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

func New

func (*RedisLimiter) Allow

func (rl *RedisLimiter) Allow(ctx context.Context, key string, opts ...Option) (bool, error)

Jump to

Keyboard shortcuts

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