xcounter

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FrequencyCounter

type FrequencyCounter struct {
	// contains filtered or unexported fields
}

FrequencyCounter keeps track of the frequency counts for the previous interval and the current interval

func NewFrequencyCounter

func NewFrequencyCounter(opts Options) FrequencyCounter

NewFrequencyCounter creates a new frequency counter

func (*FrequencyCounter) Count

func (c *FrequencyCounter) Count(dur time.Duration) int64

Count returns the frequency count between now - dur and now

func (*FrequencyCounter) Record

func (c *FrequencyCounter) Record(n int64)

Record records a frequency value in the corresponding bucket

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options controls the parameters for frequency counters

func NewOptions

func NewOptions() Options

NewOptions creates new options

func (Options) Interval

func (o Options) Interval() time.Duration

Interval returns the interval associated with each bucket

func (Options) NumBuckets

func (o Options) NumBuckets() int

NumBuckets returns the number of buckets

func (Options) SetInterval

func (o Options) SetInterval(value time.Duration) Options

SetInterval sets the interval

func (Options) SetNumBuckets

func (o Options) SetNumBuckets(value int) Options

SetNumBuckets sets the number of buckets

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL