meter

package
v1.10.17-rc.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: BSD-3-Clause Imports: 2 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContinuousFactory

type ContinuousFactory struct{}

ContinuousFactory implements the Factory interface by returning a continuous time meter.

func (ContinuousFactory) New

func (ContinuousFactory) New(halflife time.Duration) Meter

type Factory

type Factory interface {
	// New returns a new meter with the provided halflife.
	New(halflife time.Duration) Meter
}

Factory returns new meters.

type Meter

type Meter interface {
	// Inc the meter, the read value will be monotonically increasing while
	// the meter is running.
	Inc(time.Time, float64)

	// Dec the meter, the read value will be exponentially decreasing while the
	// meter is off.
	Dec(time.Time, float64)

	// Read the current value of the meter, this can be used to approximate the
	// percent of time the meter has been running recently. The definition of
	// recently depends on the halflife of the decay function.
	Read(time.Time) float64

	// Returns the duration between [now] and when the value of this meter
	// reaches [value], assuming that the number of cores running is always 0.
	// If the value of this meter is already <= [value], returns the zero duration.
	TimeUntil(now time.Time, value float64) time.Duration
}

Meter tracks a continuous exponential moving average of the % of time this meter has been running.

func NewMeter

func NewMeter(halflife time.Duration) Meter

NewMeter returns a new Meter with the provided halflife

Jump to

Keyboard shortcuts

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