counter

package
v0.4.60 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: ISC Imports: 9 Imported by: 1

Documentation

Overview

Counter is a counter without rate information.

Datapoint tracks a fluctuating value with average. Thread-safe.

RateCounter is a value/running/max counter with averaging.

Index

Constants

This section is empty.

Variables

View Source
var CountersFactory parl.CountersFactory = &countersFactory{}

Functions

func InitAverager

func InitAverager(averagerp *Averager, size int)

func NewRunner

func NewRunner() (run *runner)

Types

type Averager

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

func (*Averager) Add

func (av *Averager) Add(value uint64) (average float64)

type Counter

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

Counter is a counter without rate information. Thread-safe.

  • value: monotonically increasing affected by method Inc
  • running: value of Inc - Dec
  • max: the highest historical value of running
  • Counter implements parl.Counter and parl.CounterValues.

Note: because Counter uses atomics and not lock, data integrity is not guaranteed or achievable. Data is valid and consistent but may be of progressing revision.

func (*Counter) Add

func (cn *Counter) Add(delta int64) (counter parl.Counter)

func (*Counter) Clone

func (cn *Counter) Clone() (counterValues parl.CounterValues)

func (*Counter) CloneReset

func (cn *Counter) CloneReset(stopRateCounters bool) (counterValues parl.CounterValues)

func (*Counter) Dec

func (cn *Counter) Dec() (counter parl.Counter)

func (*Counter) Get

func (cn *Counter) Get() (value, running, max uint64)

func (*Counter) Inc

func (cn *Counter) Inc() (counter parl.Counter)

func (*Counter) Value

func (cn *Counter) Value() (value uint64)

type Counters

type Counters struct {
	RateRunner
	// contains filtered or unexported fields
}

Counters is a container for counters, rate-counters and datapoints. Thread-Safe.

  • a counter is Inc-Dec with: value running max
  • a rate-counter is a counter with addtional measuring over short time periods:
  • — value: rate of increase: current/max/average
  • — running: rate up or down, max increase/decrease rate,

func (*Counters) DatapointMax added in v0.4.41

func (cs *Counters) DatapointMax(name parl.CounterID) (datapointMax uint64)

func (*Counters) DatapointMin added in v0.4.41

func (cs *Counters) DatapointMin(name parl.CounterID) (datapointMin uint64)

func (*Counters) DatapointValue added in v0.4.41

func (cs *Counters) DatapointValue(name parl.CounterID) (datapointValue uint64)

func (*Counters) Exists added in v0.4.41

func (cs *Counters) Exists(name parl.CounterID) (exists bool)

func (*Counters) Get added in v0.4.47

func (cs *Counters) Get(name parl.CounterID) (value, running, max uint64)

func (*Counters) GetCounters

func (cs *Counters) GetCounters() (list []parl.CounterID, m map[parl.CounterID]any)

func (*Counters) GetDatapoint added in v0.4.41

func (cs *Counters) GetDatapoint(name parl.CounterID) (value, max, min uint64, isValid bool, average float64, n uint64)

func (*Counters) GetOrCreateCounter

func (cs *Counters) GetOrCreateCounter(name parl.CounterID, period ...time.Duration) (counter parl.Counter)

func (*Counters) GetOrCreateDatapoint

func (cs *Counters) GetOrCreateDatapoint(name parl.CounterID, period time.Duration) (datapoint parl.Datapoint)

func (*Counters) Rates added in v0.4.41

func (cs *Counters) Rates(name parl.CounterID) (rates map[parl.RateType]int64)

func (*Counters) ResetCounters

func (cs *Counters) ResetCounters(stopRateCounters bool)

func (*Counters) Value added in v0.4.41

func (cs *Counters) Value(name parl.CounterID) (value uint64)

type Datapoint

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

Datapoint tracks a fluctuating value with average. Thread-safe.

func (*Datapoint) CloneDatapoint

func (dt *Datapoint) CloneDatapoint() (datapoint parl.Datapoint)

func (*Datapoint) CloneDatapointReset

func (dt *Datapoint) CloneDatapointReset() (datapoint parl.Datapoint)

func (*Datapoint) DatapointMax

func (dt *Datapoint) DatapointMax() (max uint64)

func (*Datapoint) DatapointMin

func (dt *Datapoint) DatapointMin() (min uint64)

func (*Datapoint) DatapointValue

func (dt *Datapoint) DatapointValue() (value uint64)

func (*Datapoint) GetDatapoint

func (dt *Datapoint) GetDatapoint() (value, max, min uint64, isValid bool, average float64, n uint64)

func (*Datapoint) SetValue

func (dt *Datapoint) SetValue(value uint64) (datapoint parl.Datapoint)

SetValue records a new datapoint value

type Rate

type Rate struct {
	RateType // String()
	// contains filtered or unexported fields
}

func (*Rate) Clone

func (rt *Rate) Clone() (rate parl.Rate)

func (*Rate) Delta

func (rt *Rate) Delta() (delta uint64)

func (*Rate) Duration

func (rt *Rate) Duration() (duration time.Duration)

func (*Rate) HasValue

func (rt *Rate) HasValue() (hasValue bool)

type RateCounter

type RateCounter struct {
	Counter // value-running-max atomic-access container
	// contains filtered or unexported fields
}

RateCounter is a value/running/max counter with averaging.

  • rate of increase, maximum and average rate of increase in value
  • rate of increase, maximum increase and decrease rates and average of value

func (*RateCounter) Do

func (rc *RateCounter) Do()

func (*RateCounter) Rates

func (rc *RateCounter) Rates() (rates map[parl.RateType]int64)

type RateRunner

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

func NewRateRunner

func NewRateRunner(g0 parl.GoGen) (rr *RateRunner)

func (*RateRunner) AddTask

func (rr *RateRunner) AddTask(period time.Duration, task RateRunnerTask)

type RateRunnerTask

type RateRunnerTask interface {
	Do()
}

type RateType

type RateType parl.RateType

func (RateType) String

func (rt RateType) String() (s string)

Jump to

Keyboard shortcuts

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