ratelimit

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TTL             time.Duration
	MaxEntries      int
	Policy          func(r *http.Request) (bucket string, pol RatePolicy, ok bool)
	IPManager       *zulu.IPManager
	CleanupInterval time.Duration
	SharedState     woos.SharedState
}

type RateLimiter

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

func New

func New(cfg Config) *RateLimiter

New instantiates a dynamic request throttling layer. Handles both local token buckets and shared cluster constraints automatically.

func (*RateLimiter) Close

func (rl *RateLimiter) Close()

Close terminates the background cleanup scheduler and flushes map data. Prevents memory leaks during proxy hot-reloads and shutdowns.

func (*RateLimiter) Handler

func (rl *RateLimiter) Handler(next http.Handler) http.Handler

Handler enforces endpoint request ceilings across incoming connections. Responds with 429 Too Many Requests instantly upon limit saturation.

type RatePolicy

type RatePolicy struct {
	Requests int
	Window   time.Duration
	Burst    int
	KeySpec  string
}

Jump to

Keyboard shortcuts

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