counter

package
v0.0.0-...-41c389d Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter interface {
	Add(int64)
	Reset()
	Value() int64
}

Counter is a counter interface.

func NewGauge

func NewGauge() Counter

NewGauge return a guage counter.

func NewRolling

func NewRolling(window time.Duration, winBucket int) Counter

NewRolling creates a new window. windowTime is the time covering the entire window. windowBuckets is the number of buckets the window is divided into. An example: a 10 second window with 10 buckets will have 10 buckets covering 1 second each.

type Group

type Group struct {

	// New optionally specifies a function to generate a counter.
	// It may not be changed concurrently with calls to other functions.
	New func() Counter
	// contains filtered or unexported fields
}

Group is a counter group.

func (*Group) Add

func (g *Group) Add(key string, value int64)

Add add a counter by a specified key, if counter not exists then make a new one and return new value.

func (*Group) Reset

func (g *Group) Reset(key string)

Reset reset a counter by key.

func (*Group) Value

func (g *Group) Value(key string) int64

Value get a counter value by key.

Jump to

Keyboard shortcuts

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