Categorygithub.com/opencoff/go-ratelimit
modulepackage
0.9.0
Repository: https://github.com/opencoff/go-ratelimit.git
Documentation: pkg.go.dev

# README

go-ratelimit - Simple wrapper around golang.org/x/time/rate

What is it?

Token bucket ratelimiter for golang; it wraps the Limiter in golang.org/x/time/rate. It implements global and per-host rate limits. It uses an LRU cache to cache the most frequently used per-host limiters.

# Packages

Package ratelimit implements a token bucket rate limiter.

# Functions

Create a new token bucket rate limiter that limits globally at 'g' requests/sec and per-host at 'p' requests/sec; It remembers the rate of the 'cachesize' most recent hosts (and their limits).

# Structs

Limiter controls how frequently events are allowed to happen globally or per-host.