// Package throttle - token bucket rate limiting. package throttle import "context" // TokenBucket represents the storage backend for token bucket rate limiting. type TokenBucket interface { // Take removes one token from the bucket for the given key. // Creates the bucket with the given capacity if it doesn't exist. // Returns true if a token was available (request allowed), false if denied. Take(ctx context.Context, key string, capacity int, refillRate float64) (bool, error) // Reset refills the bucket for the given key. Reset(ctx context.Context, key string) error }