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

memorylimiter

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limit

type Limit struct {
	Limit  int
	Window time.Duration
}

Limit defines window and max count for a bucket.

type Limiter

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

Limiter is an in-memory sliding-window rate limiter. It is intended as a single-node fallback when Redis is unavailable.

func New

func New(limits map[string]Limit) *Limiter

New constructs a new in-memory limiter with the provided per-bucket limits.

func (*Limiter) AllowNamed

func (l *Limiter) AllowNamed(bucket, key string) (bool, error)

AllowNamed matches the auth adapter's RateLimiter interface. It uses a simple sliding window over the configured duration, pruning expired entries on each call and removing empty buckets to avoid unbounded memory growth.

Jump to

Keyboard shortcuts

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