ratelimit

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEFAULT_WINDOW = 60
	DEFAULT_LIMIT  = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UserCounter

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

type WindowCounter

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

WindowCounter implements a simple window counter

func NewWindowCounter

func NewWindowCounter(windowSeconds, limit int) *WindowCounter

NewWindowCounter returns a limiter that allows limit requests per key every windowSeconds. Non-positive values fall back to DEFAULT_WINDOW and DEFAULT_LIMIT.

func (*WindowCounter) Allow

func (rl *WindowCounter) Allow(userID string) bool

Jump to

Keyboard shortcuts

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