lineproto

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package lineproto wraps influxdb lineprotocol. Deprecated: use point package.

Index

Constants

View Source
const (
	WarnMaxTags               = "warn_exceed_max_tags"
	WarnMaxFields             = "warn_exceed_max_fields"
	WarnMaxTagKeyLen          = "warn_exceed_max_tag_key_len"
	WarnMaxFieldKeyLen        = "warn_exceed_max_field_key_len"
	WarnMaxTagValueLen        = "warn_exceed_max_tag_value_len"
	WarnMaxFieldValueLen      = "warn_exceed_max_field_value_len"
	WarnMaxFieldValueInt      = "warn_exceed_max_field_value_int"
	WarnSameTagFieldKey       = "warn_same_tag_field_key"
	WarnInvalidFieldValueType = "warn_invalid_field_value_type"
)
View Source
const (
	Nanosecond  = lp.Nanosecond
	Microsecond = lp.Microsecond
	Millisecond = lp.Millisecond
	Second      = lp.Second
)

Variables

View Source
var DefaultOption = NewDefaultOption()

Functions

func Encode

func Encode(pts []*Point, opt ...OptionSetter) ([]byte, error)

func GetSafeString

func GetSafeString(s string) string

GetSafeString get a copy of string s.

func InterfaceToValue

func InterfaceToValue(x interface{}) (lp.Value, bool)

func MakeLineProtoPoint

func MakeLineProtoPoint(name string,
	tags map[string]string,
	fields map[string]interface{},
	opt *Option,
) (*influxdb.Point, error)

func MakeLineProtoPointWithWarningsV2

func MakeLineProtoPointWithWarningsV2(name string,
	tags map[string]string,
	fields map[string]interface{},
	opt *Option,
) (pt *Point, warnings []*PointWarning, err error)

func ParsePoints

func ParsePoints(data []byte, opt *Option) ([]*influxdb.Point, error)

Types

type Callback

type Callback func(models.Point) (models.Point, error)

type CallbackV2

type CallbackV2 func(point *Point) (*Point, error)

type LineEncoder

type LineEncoder struct {
	Encoder *lp.Encoder
	Opt     *Option
}

func NewLineEncoder

func NewLineEncoder(optionSetters ...OptionSetter) *LineEncoder

func (*LineEncoder) AppendPoint

func (le *LineEncoder) AppendPoint(pt *Point) error

func (*LineEncoder) Bytes

func (le *LineEncoder) Bytes() ([]byte, error)

Bytes return the line protocol bytes You should be **VERY CAREFUL** when using this function together with the Reset.

func (*LineEncoder) BytesWithoutLn

func (le *LineEncoder) BytesWithoutLn() ([]byte, error)

BytesWithoutLn return the line protocol bytes without the trailing new line You should be **VERY CAREFUL** when using this function together with the Reset.

func (*LineEncoder) EnableLax

func (le *LineEncoder) EnableLax()

func (*LineEncoder) Reset

func (le *LineEncoder) Reset()

func (*LineEncoder) SetBuffer

func (le *LineEncoder) SetBuffer(buf []byte)

func (*LineEncoder) UnsafeString

func (le *LineEncoder) UnsafeString() (string, error)

UnsafeString return string with no extra allocation You should be **VERY CAREFUL** when using this function together with the Reset.

func (*LineEncoder) UnsafeStringWithoutLn

func (le *LineEncoder) UnsafeStringWithoutLn() (string, error)

UnsafeStringWithoutLn return the line protocol **UNSAFE** string without the trailing new line You should be **VERY CAREFUL** when using this function together with the Reset.

type Option

type Option struct {
	Time time.Time

	DisabledTagKeys   []string
	DisabledFieldKeys []string

	Precision   string
	ExtraTags   map[string]string
	Callback    Callback
	CallbackV2  CallbackV2
	PrecisionV2 Precision

	Strict             bool
	EnablePointInKey   bool
	DisableStringField bool // disable string field value

	MaxTags,
	MaxFields,
	MaxTagKeyLen,
	MaxFieldKeyLen,
	MaxTagValueLen,
	MaxFieldValueLen int
}

func NewDefaultOption

func NewDefaultOption() *Option

type OptionSetter

type OptionSetter func(opt *Option)

func WithCallback

func WithCallback(callback Callback) OptionSetter

func WithCallbackV2

func WithCallbackV2(callback CallbackV2) OptionSetter

func WithDisableStringField

func WithDisableStringField(disableStringField bool) OptionSetter

func WithDisabledFieldKeys

func WithDisabledFieldKeys(disabledFieldKeys []string) OptionSetter

func WithDisabledTagKeys

func WithDisabledTagKeys(disabledTagKeys []string) OptionSetter

func WithEnablePointInKey

func WithEnablePointInKey(b bool) OptionSetter

func WithExtraTags

func WithExtraTags(extraTags map[string]string) OptionSetter

func WithMaxFieldKeyLen

func WithMaxFieldKeyLen(maxFieldKeyLen int) OptionSetter

func WithMaxFieldValueLen

func WithMaxFieldValueLen(maxFieldValueLen int) OptionSetter

func WithMaxFields

func WithMaxFields(maxFields int) OptionSetter

func WithMaxTagKeyLen

func WithMaxTagKeyLen(maxTagKeyLen int) OptionSetter

func WithMaxTagValueLen

func WithMaxTagValueLen(maxTagValueLen int) OptionSetter

func WithMaxTags

func WithMaxTags(maxTags int) OptionSetter

func WithPrecision

func WithPrecision(precision string) OptionSetter

func WithPrecisionV2

func WithPrecisionV2(precision Precision) OptionSetter

func WithStrict

func WithStrict(b bool) OptionSetter

func WithTime

func WithTime(time time.Time) OptionSetter

type Point

type Point struct {
	Name   string
	Tags   map[string]string
	Fields map[string]interface{}
	Time   time.Time
}

func MakeLineProtoPointV2

func MakeLineProtoPointV2(name string,
	tags map[string]string,
	fields map[string]interface{},
	opt *Option,
) (*Point, error)

func NewPoint

func NewPoint(name string,
	tags map[string]string,
	fields map[string]interface{},
	t ...time.Time,
) (*Point, error)

func Parse

func Parse(data []byte, opt *Option) ([]*Point, error)

func ParseWithOptionSetter

func ParseWithOptionSetter(data []byte, optionSetters ...OptionSetter) ([]*Point, error)

func (*Point) AddField

func (p *Point) AddField(key string, val interface{}) error

func (*Point) AddTag

func (p *Point) AddTag(key, val string)

func (*Point) String

func (p *Point) String() (string, error)

func (*Point) ToInfluxdbPoint

func (p *Point) ToInfluxdbPoint(defaultTime time.Time) (models.Point, error)

type PointWarning

type PointWarning struct {
	WarningType string
	Message     string
}

func MakeLineProtoPointWithWarnings

func MakeLineProtoPointWithWarnings(name string,
	tags map[string]string,
	fields map[string]interface{},
	opt *Option,
) (pt *influxdb.Point, warnings []*PointWarning, err error)

type Precision

type Precision = lp.Precision

func ConvertPrecisionToV2

func ConvertPrecisionToV2(precision string) (Precision, error)

ConvertPrecisionToV2 map version 1 precision to version 2.

Jump to

Keyboard shortcuts

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