metric

package
v0.8.3-dl0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewECRate

func NewECRate(alpha float64) *etherCopyRate

func NewECRate5

func NewECRate5(tickInterval int) *etherCopyRate

func NewExponentMetric

func NewExponentMetric(interval int, meanTime int) *exponentMetric

func NewMetricManager

func NewMetricManager(interval int) *metricsManager

Types

type DataMetric

type DataMetric interface {
	// APS shows average bytes per second in a given period
	APS() int64
	// LoadScore is calulated value of network load.
	LoadScore() int64
	// add bytes transferred
	AddBytes(byteSize int)
	// Calculate should be called peridically with exact interval and a single thread
	Calculate()
}

DataMetric hold data transfer of a peer. It shows eventually consistent aps and load score.

func NewExponentMetric15

func NewExponentMetric15(tickInterval int) DataMetric

NewExponentMetric15

func NewExponentMetric5

func NewExponentMetric5(tickInterval int) DataMetric

type ListenAdded

type ListenAdded func(size int)

type MetricReader

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

func NewReader

func NewReader(rd io.Reader) *MetricReader

func (*MetricReader) AddListener

func (r *MetricReader) AddListener(listener ListenAdded)

func (*MetricReader) Read

func (r *MetricReader) Read(p []byte) (n int, err error)

type MetricWriter

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

func NewWriter

func NewWriter(wt io.Writer) *MetricWriter

func (*MetricWriter) AddListener

func (w *MetricWriter) AddListener(listener ListenAdded)

func (*MetricWriter) Write

func (w *MetricWriter) Write(p []byte) (n int, err error)

type MetricsManager

type MetricsManager interface {
	Start()
	Stop()

	Add(pid peer.ID, reader *MetricReader, writer *MetricWriter) *PeerMetric
	Remove(pid peer.ID) *PeerMetric

	Metric(pid peer.ID) (*PeerMetric, bool)
	Metrics() []*PeerMetric

	Summary() string
}

type PeerMetric

type PeerMetric struct {
	PeerID peer.ID

	Since time.Time

	InMetric  DataMetric
	OutMetric DataMetric
	// contains filtered or unexported fields
}

func (*PeerMetric) InputAdded

func (m *PeerMetric) InputAdded(added int)

func (*PeerMetric) OutputAdded

func (m *PeerMetric) OutputAdded(added int)

func (*PeerMetric) TotalIn

func (m *PeerMetric) TotalIn() int64

func (*PeerMetric) TotalOut

func (m *PeerMetric) TotalOut() int64

Jump to

Keyboard shortcuts

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