store

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

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

Aggregator will pull from the Counter on a given interval and store rates for that interval.

func NewAggregator

func NewAggregator(c RateCounter, opts ...AggregatorOption) *Aggregator

NewAggregator will return an initialized Aggregator

func (*Aggregator) Rate

func (a *Aggregator) Rate(timestamp int64) (Rate, error)

Rate returns the rates for a single time period.

func (*Aggregator) Rates

func (a *Aggregator) Rates() Rates

Rates returns the current state of the aggregator.

func (*Aggregator) Run

func (a *Aggregator) Run()

Run starts the aggregator. This method will block indefinitely.

type AggregatorOption

type AggregatorOption func(a *Aggregator)

AggregatorOption are funcs that can be used to configure an Aggregator at initialization.

func WithMaxRateBuckets

func WithMaxRateBuckets(n int) AggregatorOption

WithMaxRateBuckets returns an AggregatorOption to configure the max number of Rate bucketes to store.

func WithPollingInterval

func WithPollingInterval(d time.Duration) AggregatorOption

WithPollingInterval returns an AggregatorOption to configure the polling interval. The polling interval determines how often the aggregator will poll data from the counter. The polling interval is also isued to determine the amount of time that is used for the rate. E.g. If the polling interval is 1 minute, then rates are calculated as number of logs per minute.

type Counter

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

Counter stores data about the number of logs emitted per application.

func NewCounter

func NewCounter() *Counter

NewCounter returns an initialized counter.

func (*Counter) Inc

func (c *Counter) Inc(id string)

Inc increments the value for a given ID.

func (*Counter) Reset

func (c *Counter) Reset() map[string]uint64

Reset returns the current counts while replacing the current counts with an empty map.

type Rate

type Rate struct {
	Timestamp int64             `json:"timestamp"`
	Counts    map[string]uint64 `json:"counts"`
}

Rate stores data for a single polling interval.

type RateCounter

type RateCounter interface {
	Reset() map[string]uint64
}

RateCounter is the interface the Aggregator will poll data from.

type Rates

type Rates []Rate

Rates is a collection of Rate for sorting on timestamp and presentation purposes

func (Rates) Len

func (r Rates) Len() int

func (Rates) Less

func (r Rates) Less(i, j int) bool

func (Rates) Swap

func (r Rates) Swap(i, j int)

Jump to

Keyboard shortcuts

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