Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket defines the bucket that holds sum and num of additions.
type SlidingWindow ¶
type SlidingWindow struct {
// contains filtered or unexported fields
}
SlidingWindow defines a Sliding window to calculate the events in buckets with time interval.
func NewSlidingWindow ¶
func NewSlidingWindow(size int, interval time.Duration, opts ...SlidingWindowOption) *SlidingWindow
NewSlidingWindow returns a SlidingWindow that with size buckets and time interval, use opts to customize the SlidingWindow.
func (*SlidingWindow) Add ¶
func (s *SlidingWindow) Add(v float64) *SlidingWindow
Add adds value to current bucket.
func (*SlidingWindow) Reduce ¶
func (s *SlidingWindow) Reduce(fn func(b *Bucket))
Reduce runs fn on all buckets, ignore current bucket if ignoreCurrent was set.
type SlidingWindowOption ¶
type SlidingWindowOption func(*SlidingWindow)
SlidingWindowOption customize the SlidingWindow.
func IgnoreCurrentBucket ¶
func IgnoreCurrentBucket() SlidingWindowOption
IgnoreCurrentBucket ignore current bucket.
Click to show internal directories.
Click to hide internal directories.