datum

package
v3.0.0-rc25+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecIntBy

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

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

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 GetString

func GetString(d Datum) string

GetString returns the string 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.

func SetString

func SetString(d Datum, v string, ts time.Time)

SetString sets a string Datum to the provided value and timestamp, or panics if the Datym is not a String Datum

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.

func (*BaseDatum) TimeUTC

func (d *BaseDatum) TimeUTC() time.Time

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

	// Time returns the timestamp of the Datum as time.Time in UTC
	TimeUTC() time.Time
}

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 MakeString

func MakeString(v string, ts time.Time) Datum

MakeString creates a new string 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.

func NewString

func NewString() Datum

NewString creates a new zero string 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) DecBy

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

DecBy increments the IntDatum's value by the value provided, at 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 StringDatum

type StringDatum struct {
	BaseDatum

	Value string
	// contains filtered or unexported fields
}

StringDatum describes a string value at a given timestamp.

func (*StringDatum) Get

func (d *StringDatum) Get() string

Get returns the value of the StringDatum

func (*StringDatum) MarshalJSON

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

MarshalJSON returns a JSON encoding of the StringDatum.

func (*StringDatum) Set

func (d *StringDatum) Set(value string, timestamp time.Time)

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

func (*StringDatum) String

func (d *StringDatum) String() string

String returns a string representation of the StringDatum.

func (*StringDatum) Type

func (*StringDatum) Type() Type

Type returns the Type of an StringDatum, String.

func (*StringDatum) ValueString

func (d *StringDatum) ValueString() string

ValueString returns the value of the StringDatum 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
	// String describes printable strings of text
	String
)

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