line-protocol: Index | Files

package protocol

import ""


Package Files

encoder.go escape.go metric.go writer.go


var (
    // ErrNeedMoreSpace tells us that the Decoder's io.Reader is full.
    ErrNeedMoreSpace = &MetricError{"need more space"}

    // ErrInvalidName tells us that the chosen name is invalid.
    ErrInvalidName = &MetricError{"invalid name"}

    // ErrNoFields tells us that there were no serializable fields in the line/metric.
    ErrNoFields = &MetricError{"no serializable fields"}
var ErrIsInf = &FieldError{"is Inf"}

ErrIsInf is a field error for when a float field is Inf.

var ErrIsNaN = &FieldError{"is NaN"}

ErrIsNaN is a field error for when a float field is NaN.

type Encoder Uses

type Encoder struct {
    // contains filtered or unexported fields

Encoder marshals Metrics into influxdb line protocol. It is not safe for concurrent use, make a new one! The default behavior when encountering a field error is to ignore the field and move on. If you wish it to error out on field errors, use Encoder.FailOnFieldErr(true)

func NewEncoder Uses

func NewEncoder(w io.Writer) *Encoder

NewEncoder gives us an encoder that marshals to a writer in influxdb line protocol as defined by:

func (*Encoder) Encode Uses

func (e *Encoder) Encode(m Metric) (int, error)

Encode marshals a Metric to the io.Writer in the Encoder

func (*Encoder) FailOnFieldErr Uses

func (e *Encoder) FailOnFieldErr(s bool)

FailOnFieldErr whether or not to fail on a field error or just move on. The default behavior to move on

func (*Encoder) SetFieldSortOrder Uses

func (e *Encoder) SetFieldSortOrder(s FieldSortOrder)

SetFieldSortOrder sets a sort order for the data. The options are: NoSortFields (doesn't sort the fields) SortFields (sorts the keys in alphabetical order)

func (*Encoder) SetFieldTypeSupport Uses

func (e *Encoder) SetFieldTypeSupport(s FieldTypeSupport)

SetFieldTypeSupport sets flags for if the encoder supports certain optional field types such as uint64

func (*Encoder) SetMaxLineBytes Uses

func (e *Encoder) SetMaxLineBytes(i int)

SetMaxLineBytes sets a maximum length for a line, Encode will error if the generated line is longer

func (*Encoder) Write Uses

func (e *Encoder) Write(name []byte, ts time.Time, tagKeys, tagVals, fieldKeys [][]byte, fieldVals []interface{}) (int, error)

Write writes out data to a line protocol encoder. Note: it does no sorting. It assumes you have done your own sorting for tagValues

type Field Uses

type Field struct {
    Key   string
    Value interface{}

Field holds the keys and values for a bunch of Metric Field k/v pairs where Value can be a uint64, int64, int, float32, float64, string, or bool.

type FieldError Uses

type FieldError struct {
    // contains filtered or unexported fields

FieldError is an error causing a field to be unserializable.

func (FieldError) Error Uses

func (e FieldError) Error() string

type FieldSortOrder Uses

type FieldSortOrder int

FieldSortOrder is a type for controlling if Fields are sorted

const (
    // NoSortFields tells the Decoder to not sort the fields.
    NoSortFields FieldSortOrder = iota

    // SortFields tells the Decoder to sort the fields.

type FieldTypeSupport Uses

type FieldTypeSupport int

FieldTypeSupport is a type for the parser to understand its type support.

const (
    // UintSupport means the parser understands uint64s and can store them without having to convert to int64.
    UintSupport FieldTypeSupport = 1 << iota

type Metric Uses

type Metric interface {
    Time() time.Time
    Name() string
    TagList() []*Tag
    FieldList() []*Field

Metric is the interface for marshaling, if you implement this interface you can be marshalled into the line protocol. Woot!

type MetricError Uses

type MetricError struct {
    // contains filtered or unexported fields

MetricError is an error causing a metric to be unserializable.

func (MetricError) Error Uses

func (e MetricError) Error() string

type Tag Uses

type Tag struct {
    Key   string
    Value string

Tag holds the keys and values for a bunch of Tag k/v pairs.

Package protocol imports 9 packages (graph) and is imported by 3 packages. Updated 2019-05-12. Refresh now. Tools for package owners.