Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
LocalWindow represents a window that ignores sync behavior entirely and only stores counters in memory.
func NewLimiter ¶
NewLimiter returns a new Limiter that limits events to max events per interval duration.
func (*Limiter) Allow ¶
Allow checks if the rate limit would be exceeded by calling add. If the limit would be exceeded, Allow returns false and the remaining duration until the next event can happen. If the event can happen immediately, Allow calls add to increment the count and returns true.
func (*Limiter) AllowForce ¶
AllowForce unconditionally increments the rate limiter count and returns true, without checking if the rate limit would be exceeded. This allows forcing an event through even if the rate limit has been reached.
func (*Limiter) Check ¶
Check returns whether the rate limit would be exceeded if an event is added now. It returns a bool indicating if the limit would be exceeded, and a time.Duration for the remaining time until the next event can happen without exceeding the rate limit.
func (*Limiter) CheckBool ¶
CheckBool checks if the rate limit would be exceeded by calling add. It returns a boolean indicating whether the rate limit would be exceeded or not.