influxdbsubscribe

package
v0.3.9-9 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MinNanoTime is the minumum time that can be represented.
	//
	// 1677-09-21 00:12:43.145224194 +0000 UTC
	//
	// The two lowest minimum integers are used as sentinel values.  The
	// minimum value needs to be used as a value lower than any other value for
	// comparisons and another separate value is needed to act as a sentinel
	// default value that is unusable by the user, but usable internally.
	// Because these two values need to be used for a special purpose, we do
	// not allow users to write points at these two times.
	MinNanoTime = int64(math.MinInt64) + 2

	// MaxNanoTime is the maximum time that can be represented.
	//
	// 2262-04-11 23:47:16.854775806 +0000 UTC
	//
	// The highest time represented by a nanosecond needs to be used for an
	// exclusive range in the shard group, so the maximum time needs to be one
	// less than the possible maximum number of nanoseconds representable by an
	// int64 so that we don't lose a point at that one time.
	MaxNanoTime = int64(math.MaxInt64) - 1
)
View Source
const (
	MaxKeyLength = 65535
)

Variables

View Source
var (
	ErrPointMustHaveAField  = errors.New("point without fields is unsupported")
	ErrInvalidNumber        = errors.New("invalid number")
	ErrInvalidPoint         = errors.New("point is invalid")
	ErrMaxKeyLengthExceeded = errors.New("max key length exceeded")
)
View Source
var (
	Codes = map[byte][]byte{
		',': []byte(`\,`),
		'"': []byte(`\"`),
		' ': []byte(`\ `),
		'=': []byte(`\=`),
	}
)
View Source
var (

	// ErrTimeOutOfRange gets returned when time is out of the representable range using int64 nanoseconds since the epoch.
	ErrTimeOutOfRange = fmt.Errorf("time outside range %d - %d", MinNanoTime, MaxNanoTime)
)

Functions

func AppendUnescaped

func AppendUnescaped(dst, src []byte) []byte

func CheckTime

func CheckTime(t time.Time) error

CheckTime checks that a time is within the safe range.

func EscapeStringField

func EscapeStringField(in string) string

EscapeStringField returns a copy of in with any double quotes or backslashes with escaped values

func GetPrecisionMultiplier

func GetPrecisionMultiplier(precision string) int64

GetPrecisionMultiplier will return a multiplier for the precision specified

func GetString

func GetString(in string) string

func IsEscaped

func IsEscaped(b []byte) bool

func MakeKey

func MakeKey(name []byte, tags Tags) []byte

MakeKey creates a key for a set of tags.

func SafeCalcTime

func SafeCalcTime(timestamp int64, precision string) (time.Time, error)

SafeCalcTime safely calculates the time given. Will return error if the time is outside the supported range.

func Unescape

func Unescape(in []byte) []byte

func UnescapeString

func UnescapeString(in string) string

Types

type FieldIterator

type FieldIterator interface {
	Next() bool
	FieldKey() []byte
	Type() FieldType
	StringValue() string
	IntegerValue() int64
	BooleanValue() bool
	FloatValue() float64

	Delete()
	Reset()
}

type FieldType

type FieldType int
const (
	Integer FieldType = iota
	Float
	Boolean
	String
	Empty
)

type Fields

type Fields map[string]interface{}

Fields represents a mapping between a Point's field names and their values.

func (Fields) MarshalBinary

func (p Fields) MarshalBinary() []byte

MarshalBinary encodes all the fields to their proper type and returns the binary represenation NOTE: uint64 is specifically not supported due to potential overflow when we decode again later to an int64 NOTE2: uint is accepted, and may be 64 bits, and is for some reason accepted...

type Point

type Point interface {
	Name() string
	SetName(string)

	Tags() Tags
	AddTag(key, value string)
	SetTags(tags Tags)

	Fields() Fields

	Time() time.Time
	SetTime(t time.Time)
	UnixNano() int64

	Key() []byte

	Data() []byte
	SetData(buf []byte)

	// String returns a string representation of the point, if there is a
	// timestamp associated with the point then it will be specified with the default
	// precision of nanoseconds
	String() string

	// Bytes returns a []byte representation of the point similar to string.
	MarshalBinary() ([]byte, error)

	// PrecisionString returns a string representation of the point, if there
	// is a timestamp associated with the point then it will be specified in the
	// given unit
	PrecisionString(precision string) string

	// RoundedString returns a string representation of the point, if there
	// is a timestamp associated with the point, then it will be rounded to the
	// given duration
	RoundedString(d time.Duration) string

	// Split will attempt to return multiple points with the same timestamp whose
	// string representations are no longer than size. Points with a single field or
	// a point without a timestamp may exceed the requested size.
	Split(size int) []Point

	// Round will round the timestamp of the point to the given duration
	Round(d time.Duration)

	// StringSize returns the length of the string that would be returned by String()
	StringSize() int

	// AppendString appends the result of String() to the provided buffer and returns
	// the result, potentially reducing string allocations
	AppendString(buf []byte) []byte

	// FieldIterator retuns a FieldIterator that can be used to traverse the
	// fields of a point without constructing the in-memory map
	FieldIterator() FieldIterator
}

Point defines the values that will be written to the database

func MustNewPoint

func MustNewPoint(name string, tags Tags, fields Fields, time time.Time) Point

MustNewPoint returns a new point with the given measurement name, tags, fields and timestamp. If an unsupported field value (NaN) is passed, this function panics.

func NewPoint

func NewPoint(name string, tags Tags, fields Fields, t time.Time) (Point, error)

NewPoint returns a new point with the given measurement name, tags, fields and timestamp. If an unsupported field value (NaN) or out of range time is passed, this function returns an error.

func NewPointFromBytes

func NewPointFromBytes(b []byte) (Point, error)

NewPointFromBytes returns a new Point from a marshalled Point.

func ParsePoints

func ParsePoints(buf []byte) ([]Point, error)

ParsePoints returns a slice of Points from a text representation of a point with each point separated by newlines. If any points fail to parse, a non-nil error will be returned in addition to the points that parsed successfully.

func ParsePointsString

func ParsePointsString(buf string) ([]Point, error)

ParsePointsString is identical to ParsePoints but accepts a string buffer.

func ParsePointsWithPrecision

func ParsePointsWithPrecision(buf []byte, defaultTime time.Time, precision string) ([]Point, error)

ParsePointsWithPrecision is similar to ParsePoints, but allows the caller to provide a precision for time.

NOTE: to minimize heap allocations, the returned Points will refer to subslices of buf. This can have the unintended effect preventing buf from being garbage collected.

type Points

type Points []Point

Points represents a sortable list of points by timestamp.

func (Points) Len

func (a Points) Len() int

func (Points) Less

func (a Points) Less(i, j int) bool

func (Points) Swap

func (a Points) Swap(i, j int)

type Tag

type Tag struct {
	Key   []byte
	Value []byte
}

Tag represents a single key/value tag pair.

func (Tag) Clone

func (t Tag) Clone() Tag

Clone returns a shallow copy of Tag.

Tags associated with a Point created by ParsePointsWithPrecision will hold references to the byte slice that was parsed. Use Clone to create a Tag with new byte slices that do not refer to the argument to ParsePointsWithPrecision.

type Tags

type Tags []Tag

Tags represents a sorted list of tags.

func NewTags

func NewTags(m map[string]string) Tags

NewTags returns a new Tags from a map.

func ParseKey

func ParseKey(buf []byte) (string, Tags, error)

ParseKey returns the measurement name and tags from a point.

NOTE: to minimize heap allocations, the returned Tags will refer to subslices of buf. This can have the unintended effect preventing buf from being garbage collected.

func (Tags) Clone

func (a Tags) Clone() Tags

Clone returns a copy of the slice where the elements are a result of calling `Clone` on the original elements

Tags associated with a Point created by ParsePointsWithPrecision will hold references to the byte slice that was parsed. Use Clone to create Tags with new byte slices that do not refer to the argument to ParsePointsWithPrecision.

func (*Tags) Delete

func (a *Tags) Delete(key []byte)

Delete removes a tag by key.

func (Tags) Get

func (a Tags) Get(key []byte) []byte

Get returns the value for a key.

func (Tags) GetString

func (a Tags) GetString(key string) string

GetString returns the string value for a string key.

func (Tags) HashKey

func (a Tags) HashKey() []byte

HashKey hashes all of a tag's keys.

func (Tags) Len

func (a Tags) Len() int

func (Tags) Less

func (a Tags) Less(i, j int) bool

func (Tags) Map

func (a Tags) Map() map[string]string

Map returns a map representation of the tags.

func (Tags) Merge

func (a Tags) Merge(other map[string]string) Tags

Merge merges the tags combining the two. If both define a tag with the same key, the merged value overwrites the old value. A new map is returned.

func (*Tags) Set

func (a *Tags) Set(key, value []byte)

Set sets the value for a key.

func (*Tags) SetString

func (a *Tags) SetString(key, value string)

SetString sets the string value for a string key.

func (Tags) Swap

func (a Tags) Swap(i, j int)

Jump to

Keyboard shortcuts

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