datum

package
v3.0.0-rc13+incompatible Latest Latest
Warning

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

Go to latest
Published: May 22, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFloat

func GetFloat(d Datum) float64

GetFloat returns the floating-point value of a datum, or error.

func GetInt

func GetInt(d Datum) int64

GetInt returns the integer value of a datum, or error.

func IncIntBy

func IncIntBy(d Datum, v int64, ts time.Time)

IncIntBy increments an integer Datum by the provided value, at time ts, or panics if the Datum is not an IntDatum.

func SetFloat

func SetFloat(d Datum, v float64, ts time.Time)

SetFloat sets a floating-point Datum to the provided value and timestamp, or panics if the Datum is not a FloatDatum.

func SetInt

func SetInt(d Datum, v int64, ts time.Time)

SetInt sets an integer datum to the provided value and timestamp, or panics if the Datum is not an IntDatum.

Types

type BaseDatum

type BaseDatum struct {
	Time int64 // nanoseconds since unix epoch
}

BaseDatum is a struct used to record timestamps across all Datum implementations.

func (*BaseDatum) TimeString

func (d *BaseDatum) TimeString() string

TimeString returns the timestamp of this Datum as a string.

type Datum

type Datum interface {
	// Type returns the Datum type.
	Type() Type

	// ValueString returns the value of a Datum as a string.
	ValueString() string

	// TimeString returns the timestamp of a Datum as a string.
	TimeString() string
}

Datum is an interface for metric datums, with a type, value and timestamp to be exported.

func MakeFloat

func MakeFloat(v float64, ts time.Time) Datum

MakeFloat creates a new floating-point datum with the provided value and timestamp.

func MakeInt

func MakeInt(v int64, ts time.Time) Datum

MakeInt creates a new integer datum with the provided value and timestamp.

func NewFloat

func NewFloat() Datum

NewFloat creates a new zero floating-point datum.

func NewInt

func NewInt() Datum

NewInt creates a new zero integer datum.

type FloatDatum

type FloatDatum struct {
	BaseDatum
	Valuebits uint64
}

FloatDatum describes a floating point value at a given timestamp.

func (*FloatDatum) Get

func (d *FloatDatum) Get() float64

Get returns the floating-point value.

func (*FloatDatum) MarshalJSON

func (d *FloatDatum) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the FloatDatum.

func (*FloatDatum) Set

func (d *FloatDatum) Set(v float64, ts time.Time)

Set sets value of the FloatDatum at the timestamp ts.

func (*FloatDatum) String

func (d *FloatDatum) String() string

String returns a string representation of the FloatDatum.

func (*FloatDatum) Type

func (*FloatDatum) Type() Type

Type returns the Type of this Datum.

func (*FloatDatum) ValueString

func (d *FloatDatum) ValueString() string

ValueString returns the value of the FloatDatum as a string.

type IntDatum

type IntDatum struct {
	BaseDatum
	Value int64
}

IntDatum describes an integer value at a given timestamp.

func (*IntDatum) Get

func (d *IntDatum) Get() int64

Get returns the value of the IntDatum

func (*IntDatum) IncBy

func (d *IntDatum) IncBy(delta int64, timestamp time.Time)

IncBy increments the IntDatum's value by the value provided, at timestamp.

func (*IntDatum) MarshalJSON

func (d *IntDatum) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the IntDatum.

func (*IntDatum) Set

func (d *IntDatum) Set(value int64, timestamp time.Time)

Set sets the value of the IntDatum to the value at timestamp.

func (*IntDatum) String

func (d *IntDatum) String() string

String returns a string representation of the IntDatum.

func (*IntDatum) Type

func (*IntDatum) Type() Type

Type returns the Type of an IntDatum, Int.

func (*IntDatum) ValueString

func (d *IntDatum) ValueString() string

ValueString returns the value of the IntDatum as a string.

type Type

type Type int

Type describes the type of value stored in a Datum.

const (
	// Int describes an integer datum
	Int Type = iota
	// Float describes a floating point datum
	Float
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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