rate

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map records the cumulative rate, since the last call to Get or GetAll, for each ID.

func NewMap

func NewMap() *Map

func (*Map) Get

func (m *Map) Get(id string) (Rate, bool)

Get reads the accumulated rate information for the specified ID. The information is marked as observed and is reset at next write.

func (*Map) GetAll

func (m *Map) GetAll() map[string]Rate

GetAll reads and removes all accumulated rate information. The information is marked as observed and is reset at next write.

func (*Map) Update

func (m *Map) Update(id string, count uint64, elapsed time.Duration)

Update adds the new rate information to the existing information. If the existing rate information is marked as observed, then it is reset before applying the new information.

type Rate

type Rate struct {
	Count   uint64
	Elapsed time.Duration
	Samples int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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