Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestRateLimiter_Allow ¶
Types ¶
type RateLimitEvent ¶
type RateLimitEvent struct { Key string Timestamp time.Time Message string ExpirationTimestamp time.Time }
RateLimitEvent represents an event when both buckets are exhausted.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter controls the rate of requests using a two-bucket leaky bucket algorithm
func NewRateLimiter ¶
func NewRateLimiter(primaryCapacity int, secondaryCapacity int, rate int) *RateLimiter
NewRateLimiter creates a new RateLimiter with the specified capacities and refill rate
func (*RateLimiter) AddListener ¶
func (rl *RateLimiter) AddListener(listener event.EventListener)
AddListener adds an event listener to the rate limiter.
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow(key string) bool
Allow checks if a request can be processed
Click to show internal directories.
Click to hide internal directories.