ratelimit

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ratelimit implements a sliding-window request limiter.

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 admits at most rpm requests per rolling minute.

func New

func New(rpm int) *Limiter

New returns a limiter admitting rpm requests per minute. rpm <= 0 returns nil, which Allow treats as unlimited.

func (*Limiter) Allow

func (l *Limiter) Allow() (ok bool, retryAfter time.Duration)

Allow reports whether one more request fits in the window and, when it does not, how long the caller should wait before retrying.

Jump to

Keyboard shortcuts

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