Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rate ¶
type Rate struct {
// contains filtered or unexported fields
}
func New ¶
New returns a new rate tracker with a defined window size that must be greater than one millisecond.
func (*Rate) Add ¶
add uses the current time and rounds it down to a window and increments the window's value.
func (*Rate) Rate ¶
rate uses the current window and previous windows' counter to compute a moving-window rate in seconds. the rate is computed by first calculating how far along the current time is in the current window as a ratio between 0 and 1.0. Then, the sum of currentWindowCount + (1 - ratio) * previousWindowCounter is returned as the interpolated counter between the two windows.
Click to show internal directories.
Click to hide internal directories.