ratelimit

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-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 Limiter

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

Limiter warps redis_rate.Limiter

func NewLimiter

func NewLimiter(rdb *redis.Client) *Limiter

NewLimiter creates a new rate limiter backed by Redis

func (*Limiter) Allow

func (l *Limiter) Allow(ctx context.Context, key string, limit int, window time.Duration) (*redis_rate.Result, error)

Allow checks if the request is allowed limit: max requests allowd window: time window Example: Allow("ip:127.0.0.1", 100, time.Minute) means 100 reqs per minute

Jump to

Keyboard shortcuts

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