Documentation
¶
Overview ¶
Package ratelimit provides a sliding-window event counter. It is a usage tracker, not a token bucket: callers record events and ask how many events fall inside the configured window ending now. Useful for transmit governor rate caps where we want to say "no more than N packets/min on this channel" without ever blocking a submit call.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window tracks events over a fixed duration. Not safe for concurrent use without the internal lock held; all exported methods take it.
func New ¶
New returns a Window of the given duration using time.Now as its clock. Panics if window <= 0.
func NewWithClock ¶
NewWithClock returns a Window with a caller-supplied clock. Panics if window <= 0 or now == nil.