Documentation
¶
Overview ¶
Package throttle provides a flush rate limiter to prevent thundering herd.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Throttle ¶
type Throttle struct {
// contains filtered or unexported fields
}
Throttle prevents thundering herd flushes by enforcing a minimum cooldown between flush operations. Without throttling, every Record() call above a batch threshold can spawn a new flush goroutine, creating unbounded HTTP POSTs.
Usage: call TryFlush() before spawning a flush goroutine. It atomically claims a flush slot if the cooldown has elapsed. Call RecordFlush() from the flush function itself (e.g., ticker-triggered flushes that bypass TryFlush).
func (*Throttle) RecordFlush ¶
func (t *Throttle) RecordFlush()
RecordFlush updates the last flush timestamp. Use this for flushes triggered by the background ticker (which bypass TryFlush).