ratelimit

package
v1.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

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

RateLimiter implements a token bucket rate limiter to prevent excessive API calls

func New

func New(maxRequests int, perDuration time.Duration, minInterval time.Duration) *RateLimiter

New creates a new rate limiter maxRequests: maximum number of requests allowed perDuration: time window for maxRequests (e.g., 60 requests per minute) minInterval: minimum time between requests (prevents burst requests)

func (*RateLimiter) Wait

func (rl *RateLimiter) Wait(ctx context.Context) error

Wait blocks until a token is available, respecting rate limits

Jump to

Keyboard shortcuts

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