Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MaxBuckets is the maximum number of rate limit buckets kept in memory. // When exceeded, stale buckets (fully refilled and older than their window) are evicted. MaxBuckets = 10000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter implements a token-bucket rate limiter keyed by scope and agent.
func (*Limiter) Allow ¶
Allow checks whether a request identified by key is within the rate limit. maxRequests is the maximum number of requests allowed in the given window. Returns nil if allowed, or an error describing the limit.
func (*Limiter) BucketCount ¶ added in v0.5.0
BucketCount returns the current number of tracked buckets (for testing).
Click to show internal directories.
Click to hide internal directories.