structs

package
v0.10.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Binary SI Byte Units
	UnitKiB = "KiB"
	UnitMiB = "MiB"
	UnitGiB = "GiB"
	UnitTiB = "TiB"
	UnitPiB = "PiB"
	UnitEiB = "EiB"

	// Decimal SI Byte Units
	UnitkB = "kB"
	UnitKB = "KB"
	UnitMB = "MB"
	UnitGB = "GB"
	UnitTB = "TB"
	UnitPB = "PB"
	UnitEB = "EB"

	// Binary SI Byte Rates
	UnitKiBPerS = "KiB/s"
	UnitMiBPerS = "MiB/s"
	UnitGiBPerS = "GiB/s"
	UnitTiBPerS = "TiB/s"
	UnitPiBPerS = "PiB/s"
	UnitEiBPerS = "EiB/s"

	// Decimal SI Byte Rates
	UnitkBPerS = "kB/s"
	UnitKBPerS = "KB/s"
	UnitMBPerS = "MB/s"
	UnitGBPerS = "GB/s"
	UnitTBPerS = "TB/s"
	UnitPBPerS = "PB/s"
	UnitEBPerS = "EB/s"

	// Hertz units
	UnitMHz = "MHz"
	UnitGHz = "GHz"

	// Watts units
	UnitmW = "mW"
	UnitW  = "W"
	UnitkW = "kW"
	UnitMW = "MW"
	UnitGW = "GW"
)

Variables

View Source
var (

	// UnitIndex is a map of unit name to unit
	UnitIndex = make(map[string]*Unit, numUnits)
)

Functions

func ConvertProtoAttributeMap

func ConvertProtoAttributeMap(in map[string]*proto.Attribute) map[string]*Attribute

func ConvertStructAttributeMap

func ConvertStructAttributeMap(in map[string]*Attribute) map[string]*proto.Attribute

func ConvertStructStatObject

func ConvertStructStatObject(in *StatObject) *proto.StatObject

ConvertStructStatObject converts between a struct and proto StatObject

func ConvertStructStatValue

func ConvertStructStatValue(in *StatValue) *proto.StatValue

ConvertStructStatValue converts between a struct and proto StatValue

func ConvertStructsAttribute

func ConvertStructsAttribute(in *Attribute) *proto.Attribute

func CopyMapStringAttribute

func CopyMapStringAttribute(in map[string]*Attribute) map[string]*Attribute

CopyMapStringAttribute copies a map of string to Attribute

func Pow

func Pow(a, b int64) int64

func ReattachConfigToGoPlugin

func ReattachConfigToGoPlugin(rc *ReattachConfig) (*plugin.ReattachConfig, error)

ReattachConfigToGoPlugin converts a ReattachConfig wrapper struct into a go plugin ReattachConfig struct

Types

type Attribute

type Attribute struct {
	// Float is the float value for the attribute
	Float *float64

	// Int is the int value for the attribute
	Int *int64

	// String is the string value for the attribute
	String *string

	// Bool is the bool value for the attribute
	Bool *bool

	// Unit is the optional unit for the set int or float value
	Unit string
}

Attribute is used to describe the value of an attribute, optionally specifying units

func ConvertProtoAttribute

func ConvertProtoAttribute(in *proto.Attribute) *Attribute

func NewBoolAttribute

func NewBoolAttribute(b bool) *Attribute

NewBoolAttribute returns a new boolean attribute.

func NewFloatAttribute

func NewFloatAttribute(f float64, unit string) *Attribute

NewFloatAttribute returns a new float attribute. The unit is not checked to be valid.

func NewIntAttribute

func NewIntAttribute(i int64, unit string) *Attribute

NewIntergerAttribute returns a new integer attribute. The unit is not checked to be valid.

func NewStringAttribute

func NewStringAttribute(s string) *Attribute

NewStringAttribute returns a new string attribute.

func ParseAttribute

func ParseAttribute(input string) *Attribute

ParseAttribute takes a string and parses it into an attribute, pulling out units if they are specified as a suffix on a number.

func (*Attribute) Comparable

func (a *Attribute) Comparable(b *Attribute) bool

Comparable returns whether the two attributes are comparable

func (*Attribute) Compare

func (a *Attribute) Compare(b *Attribute) (int, bool)

Compare compares two attributes. If the returned boolean value is false, it means the values are not comparable, either because they are of different types (bool versus int) or the units are incompatible for comparison. The returned int will be 0 if a==b, -1 if a < b, and +1 if a > b for all values but bool. For bool it will be 0 if a==b or 1 if a!=b.

func (*Attribute) Copy

func (a *Attribute) Copy() *Attribute

Copy returns a copied version of the attribute

func (*Attribute) GetBool

func (a *Attribute) GetBool() (value bool, ok bool)

GetBool returns the boolean value of the attribute or false if the attribute doesn't contain a boolean.

func (*Attribute) GetFloat

func (a *Attribute) GetFloat() (value float64, ok bool)

GetFloat returns the float value of the attribute or false if the attribute doesn't contain a float.

func (*Attribute) GetInt

func (a *Attribute) GetInt() (value int64, ok bool)

GetInt returns the integer value of the attribute or false if the attribute doesn't contain a integer.

func (*Attribute) GetString

func (a *Attribute) GetString() (value string, ok bool)

GetString returns the string value of the attribute or false if the attribute doesn't contain a string.

func (*Attribute) GoString

func (a *Attribute) GoString() string

GoString returns a string representation of the attribute

func (*Attribute) Validate

func (a *Attribute) Validate() error

Validate checks if the attribute is valid

type BaseUnit

type BaseUnit uint16

BaseUnit is a unique base unit. All units that share the same base unit should be comparable.

const (
	UnitScalar BaseUnit = iota
	UnitByte
	UnitByteRate
	UnitHertz
	UnitWatt
)

type ReattachConfig

type ReattachConfig struct {
	Protocol string
	Network  string
	Addr     string
	Pid      int
}

ReattachConfig is a wrapper around plugin.ReattachConfig to better support serialization

func ReattachConfigFromGoPlugin

func ReattachConfigFromGoPlugin(plug *plugin.ReattachConfig) *ReattachConfig

ReattachConfigFromGoPlugin converts a go plugin ReattachConfig into a ReattachConfig wrapper struct

type StatObject

type StatObject struct {
	// Nested is a mapping of object name to a nested stats object.
	Nested map[string]*StatObject

	// Attributes is a mapping of statistic name to its value.
	Attributes map[string]*StatValue
}

StatObject is a collection of statistics either exposed at the top level or via nested StatObjects.

func ConvertProtoStatObject

func ConvertProtoStatObject(in *proto.StatObject) *StatObject

ConvertProtoStatObject converts between a proto and struct StatObject

type StatValue

type StatValue struct {
	// FloatNumeratorVal exposes a floating point value. If denominator is set
	// it is assumed to be a fractional value, otherwise it is a scalar.
	FloatNumeratorVal   *float64 `json:",omitempty"`
	FloatDenominatorVal *float64 `json:",omitempty"`

	// IntNumeratorVal exposes a int value. If denominator is set it is assumed
	// to be a fractional value, otherwise it is a scalar.
	IntNumeratorVal   *int64 `json:",omitempty"`
	IntDenominatorVal *int64 `json:",omitempty"`

	// StringVal exposes a string value. These are likely annotations.
	StringVal *string `json:",omitempty"`

	// BoolVal exposes a boolean statistic.
	BoolVal *bool `json:",omitempty"`

	// Unit gives the unit type: °F, %, MHz, MB, etc.
	Unit string `json:",omitempty"`

	// Desc provides a human readable description of the statistic.
	Desc string `json:",omitempty"`
}

StatValue exposes the values of a particular statistic. The value may be of type float, integer, string or boolean. Numeric types can be exposed as a single value or as a fraction.

func ConvertProtoStatValue

func ConvertProtoStatValue(in *proto.StatValue) *StatValue

ConvertProtoStatValue converts between a proto and struct StatValue

type Unit

type Unit struct {
	// Name is the name of the unit (GiB, MB/s)
	Name string

	// Base is the base unit for the unit
	Base BaseUnit

	// Multiplier is the multiplier over the base unit (KiB multiplier is 1024)
	Multiplier int64

	// InverseMultiplier specifies that the multiplier is an inverse so:
	// Base / Multiplier. For example a mW is a W/1000.
	InverseMultiplier bool
}

Unit describes a unit and its multiplier over the base unit type

func (*Unit) Comparable

func (u *Unit) Comparable(o *Unit) bool

Comparable returns if two units are comparable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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