astistat

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DurationRatioStat

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

DurationRatioStat is an object capable of computing a duration ratio stat properly

func NewDurationRatioStat

func NewDurationRatioStat() *DurationRatioStat

NewDurationRatioStat creates a new duration ratio stat

func (*DurationRatioStat) Add

func (s *DurationRatioStat) Add(k interface{})

Add starts recording a new duration

func (*DurationRatioStat) Done

func (s *DurationRatioStat) Done(k interface{})

Done indicates the duration is now done

func (*DurationRatioStat) Start

func (s *DurationRatioStat) Start()

Start implements the StatHandler interface

func (*DurationRatioStat) Stop

func (s *DurationRatioStat) Stop()

Stop implements the StatHandler interface

func (*DurationRatioStat) Value

func (s *DurationRatioStat) Value(delta time.Duration) (o interface{})

Value implements the StatHandler interface

type IncrementStat

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

IncrementStat is an object capable of computing an increment stat properly

func NewIncrementStat

func NewIncrementStat() *IncrementStat

NewIncrementStat creates a new increment stat

func (*IncrementStat) Add

func (s *IncrementStat) Add(delta int64)

Add increments the stat

func (*IncrementStat) Start

func (s *IncrementStat) Start()

Start implements the StatHandler interface

func (*IncrementStat) Stop

func (s *IncrementStat) Stop()

Stop implements the StatHandler interface

func (*IncrementStat) Value

func (s *IncrementStat) Value(delta time.Duration) interface{}

Value implements the StatHandler interface

type Stat

type Stat struct {
	StatMetadata
	Value interface{}
}

Stat represents a stat

type StatHandler

type StatHandler interface {
	Start()
	Stop()
	Value(delta time.Duration) interface{}
}

StatHandler represents a stat handler

type StatHandlerWithoutStart

type StatHandlerWithoutStart func(delta time.Duration) interface{}

StatHandlerWithoutStart represents a stat handler that doesn't have to start or stop

func (StatHandlerWithoutStart) Start

func (h StatHandlerWithoutStart) Start()

Start implements the StatHandler interface

func (StatHandlerWithoutStart) Stop

func (h StatHandlerWithoutStart) Stop()

Stop implements the StatHandler interface

func (StatHandlerWithoutStart) Value

func (h StatHandlerWithoutStart) Value(delta time.Duration) interface{}

Value implements the StatHandler interface

type StatMetadata

type StatMetadata struct {
	Description string
	Label       string
	Unit        string
}

StatMetadata represents a stat metadata

type Stater

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

Stater is an object that can compute and handle stats

func NewStater

func NewStater(period time.Duration, fn StatsHandleFunc) *Stater

NewStater creates a new stater

func (*Stater) AddStat

func (s *Stater) AddStat(m StatMetadata, h StatHandler)

AddStat adds a stat

func (*Stater) Start

func (s *Stater) Start(ctx context.Context)

Start starts the stater

func (*Stater) StatsMetadata

func (s *Stater) StatsMetadata() (ms []StatMetadata)

StatsMetadata returns the stats metadata

func (*Stater) Stop

func (s *Stater) Stop()

Stop stops the stater

type StatsHandleFunc

type StatsHandleFunc func(stats []Stat)

StatsHandleFunc is a method that can handle stats

Jump to

Keyboard shortcuts

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