types

package
v0.0.0-...-cf6bbf6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Overview

Package types contains the various types for metric values.

Index

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) Bits

func (t Type) Bits() int

func (Type) CanToFromFloat

func (t Type) CanToFromFloat() bool

CanToFromFloat returns true if this type supports conversion to/from float64

func (Type) FromFloat

func (t Type) FromFloat(value float64) interface{}

FromFloat converts a float64 to a value according to this type FromFloat panics if this type doesn't support conversion from float64

func (Type) IsFloat

func (t Type) IsFloat() bool

func (Type) IsInt

func (t Type) IsInt() bool

func (Type) IsUint

func (t Type) IsUint() bool

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

func (t Type) SafeNilSlice() (interface{}, error)

SafeNilSlice is like NilSlice except it returns an error instead of panicing

func (Type) SafeZeroValue

func (t Type) SafeZeroValue() (interface{}, error)

SafeZeroValue is like ZeroValue except it returns an error instead of panicing

func (Type) SupportsEquality

func (t Type) SupportsEquality() bool

SupportsEquality returns true if this type supports equality.

func (Type) ToFloat

func (t Type) ToFloat(x interface{}) float64

ToFloat converts a value of this type to a float64 ToFloat panics if this type doesn't support conversion to float64

func (Type) UsesSubType

func (t Type) UsesSubType() bool

UsesSubType returns true if this type uses a sub-type.

func (Type) ZeroValue

func (t Type) ZeroValue() interface{}

ZeroValue returns the zero value for this type. ZeroValue panics if this type is Dist, List, or Unknown.

Jump to

Keyboard shortcuts

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