Documentation ¶
Overview ¶
Package types contains the various types for metric values.
Index ¶
- type Type
- func (t Type) Bits() int
- func (t Type) CanToFromFloat() bool
- func (t Type) FromFloat(value float64) interface{}
- func (t Type) IsFloat() bool
- func (t Type) IsInt() bool
- func (t Type) IsUint() bool
- func (t Type) NilSlice() interface{}
- func (t Type) SafeNilSlice() (interface{}, error)
- func (t Type) SafeZeroValue() (interface{}, error)
- func (t Type) SupportsEquality() bool
- func (t Type) ToFloat(x interface{}) float64
- func (t Type) UsesSubType() bool
- func (t Type) ZeroValue() interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Type ¶
type Type string
Type represents the type of a metric value
const ( Unknown Type = "" Bool Type = "bool" Int8 Type = "int8" Int16 Type = "int16" Int32 Type = "int32" Int64 Type = "int64" Uint8 Type = "uint8" Uint16 Type = "uint16" Uint32 Type = "uint32" Uint64 Type = "uint64" Float32 Type = "float32" Float64 Type = "float64" String Type = "string" GoTime Type = "goTime" GoDuration Type = "goDuration" Dist Type = "distribution" List Type = "list" // for JSON RPC only Time Type = "time" // for JSON RPC only Duration Type = "duration" )
func FromGoValue ¶
func FromGoValue(value interface{}) Type
FromGoValue returns the type of a value found in the GoRPC API. FromGoValue returns Unknown if it cannot determine the type. In case value is a slice of unknown type, FromGoValue returns Unknown rather than List.
func FromGoValueWithSubType ¶
func FromGoValueWithSubType(value interface{}) (kind, subType Type)
FromGoValueWithSubType returns both the type and sub-type of the value found in the GoRPC API. FromGoValueWithSubType returns Unknown, Unknown if it cannot determine the type. In case value is a slice of an unknown type, FromGoValueWithSubType returns Unknown, Unknown rather than List, Unknown.
func (Type) CanToFromFloat ¶
CanToFromFloat returns true if this type supports conversion to/from float64
func (Type) FromFloat ¶
FromFloat converts a float64 to a value according to this type FromFloat panics if this type doesn't support conversion from float64
func (Type) NilSlice ¶
func (t Type) NilSlice() interface{}
NilSlice returns the nil slice of this type. NilSlice panics if this type is Dist, List or Unknown.
func (Type) SafeNilSlice ¶
SafeNilSlice is like NilSlice except it returns an error instead of panicing
func (Type) SafeZeroValue ¶
SafeZeroValue is like ZeroValue except it returns an error instead of panicing
func (Type) SupportsEquality ¶
SupportsEquality returns true if this type supports equality.
func (Type) ToFloat ¶
ToFloat converts a value of this type to a float64 ToFloat panics if this type doesn't support conversion to float64
func (Type) UsesSubType ¶
UsesSubType returns true if this type uses a sub-type.