Documentation ¶
Overview ¶
Deprecated: this package is no longer supported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventCounter ¶
type EventCounter struct {
// contains filtered or unexported fields
}
EventCounter is used to track events over time, potentially allowing you to limit them per time period
func New ¶
func New(now time.Time, duration time.Duration) EventCounter
New returns a new EventCounter object that resets event counts per duration.
func (*EventCounter) Event ¶
func (a *EventCounter) Event(now time.Time) int64
Event returns the number of events in the time period now. Note, now should be >= the last event threshold. Also, we avoid any loops with compare and swap atomics because we're ok being off a few items as long as we're generally accurate and fast.
Click to show internal directories.
Click to hide internal directories.