write

package
v2.0.0-...-7567dab Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package write provides the Point struct

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PointToLineProtocol

func PointToLineProtocol(p *Point, precision time.Duration) string

PointToLineProtocol creates InfluxDB line protocol string from the Point, converting associated timestamp according to precision

func PointToLineProtocolBuffer

func PointToLineProtocolBuffer(p *Point, sb *strings.Builder, precision time.Duration)

PointToLineProtocolBuffer creates InfluxDB line protocol string from the Point, converting associated timestamp according to precision and write result to the string builder

Types

type Consistency

type Consistency string

Consistency defines enum for allows consistency values for InfluxDB Enterprise, as explained https://docs.influxdata.com/enterprise_influxdb/v1.9/concepts/clustering/#write-consistency

const (
	// ConsistencyOne requires at least one data node acknowledged a write.
	ConsistencyOne Consistency = "one"

	// ConsistencyAll requires all data nodes to acknowledge a write.
	ConsistencyAll Consistency = "all"

	// ConsistencyQuorum requires a quorum of data nodes to acknowledge a write.
	ConsistencyQuorum Consistency = "quorum"

	// ConsistencyAny allows for hinted hand off, potentially no write happened yet.
	ConsistencyAny Consistency = "any"
)

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options holds write configuration properties

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns Options object with default values

func (*Options) AddDefaultTag

func (o *Options) AddDefaultTag(key, value string) *Options

AddDefaultTag adds a default tag. DefaultTags are added to each written point. If a tag with the same key already exist it is overwritten. If a point already defines such a tag, it is left unchanged.

func (*Options) BatchSize

func (o *Options) BatchSize() uint

BatchSize returns size of batch

func (*Options) Consistency

func (o *Options) Consistency() Consistency

Consistency returns consistency for param value

func (*Options) DefaultTags

func (o *Options) DefaultTags() map[string]string

DefaultTags returns set of default tags

func (*Options) ExponentialBase

func (o *Options) ExponentialBase() uint

ExponentialBase returns the base for the exponential retry delay. Default 2.

func (*Options) FlushInterval

func (o *Options) FlushInterval() uint

FlushInterval returns flush interval in ms

func (*Options) MaxRetries

func (o *Options) MaxRetries() uint

MaxRetries returns maximum count of retry attempts of failed writes, default 5.

func (*Options) MaxRetryInterval

func (o *Options) MaxRetryInterval() uint

MaxRetryInterval returns the maximum delay between each retry attempt in milliseconds, default 125,000.

func (*Options) MaxRetryTime

func (o *Options) MaxRetryTime() uint

MaxRetryTime returns the maximum total retry timeout in millisecond, default 180,000.

func (*Options) Precision

func (o *Options) Precision() time.Duration

Precision returns time precision for writes

func (*Options) RetryBufferLimit

func (o *Options) RetryBufferLimit() uint

RetryBufferLimit returns retry buffer limit.

func (*Options) RetryInterval

func (o *Options) RetryInterval() uint

RetryInterval returns the default retry interval in ms, if not sent by server. Default 5,000.

func (*Options) SetBatchSize

func (o *Options) SetBatchSize(batchSize uint) *Options

SetBatchSize sets number of points sent in single request

func (*Options) SetConsistency

func (o *Options) SetConsistency(consistency Consistency) *Options

SetConsistency allows setting InfluxDB Enterprise write consistency, as explained in https://docs.influxdata.com/enterprise_influxdb/v1.9/concepts/clustering/#write-consistency */

func (*Options) SetExponentialBase

func (o *Options) SetExponentialBase(retryExponentialBase uint) *Options

SetExponentialBase sets the base for the exponential retry delay.

func (*Options) SetFlushInterval

func (o *Options) SetFlushInterval(flushIntervalMs uint) *Options

SetFlushInterval sets flush interval in ms in which is buffer flushed if it has not been already written

func (*Options) SetMaxRetries

func (o *Options) SetMaxRetries(maxRetries uint) *Options

SetMaxRetries sets maximum count of retry attempts of failed writes. Setting zero value disables retry strategy.

func (*Options) SetMaxRetryInterval

func (o *Options) SetMaxRetryInterval(maxRetryIntervalMs uint) *Options

SetMaxRetryInterval sets the maximum delay between each retry attempt in millisecond

func (*Options) SetMaxRetryTime

func (o *Options) SetMaxRetryTime(maxRetryTimeMs uint) *Options

SetMaxRetryTime sets the maximum total retry timeout in millisecond.

func (*Options) SetPrecision

func (o *Options) SetPrecision(precision time.Duration) *Options

SetPrecision sets time precision to use in writes for timestamp. In unit of duration: time.Nanosecond, time.Microsecond, time.Millisecond, time.Second

func (*Options) SetRetryBufferLimit

func (o *Options) SetRetryBufferLimit(retryBufferLimit uint) *Options

SetRetryBufferLimit sets maximum number of points to keep for retry. Should be multiple of BatchSize.

func (*Options) SetRetryInterval

func (o *Options) SetRetryInterval(retryIntervalMs uint) *Options

SetRetryInterval sets the time to wait before retry unsuccessful write in ms, if not sent by server

func (*Options) SetUseGZip

func (o *Options) SetUseGZip(useGZip bool) *Options

SetUseGZip specifies whether to use GZip compression in write requests.

func (*Options) UseGZip

func (o *Options) UseGZip() bool

UseGZip returns true if write request are gzip`ed

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point is represents InfluxDB time series point, holding tags and fields

func NewPoint

func NewPoint(
	measurement string,
	tags map[string]string,
	fields map[string]interface{},
	ts time.Time,
) *Point

NewPoint creates a Point from measurement name, tags, fields and a timestamp.

func NewPointWithMeasurement

func NewPointWithMeasurement(measurement string) *Point

NewPointWithMeasurement creates a empty Point Use AddTag and AddField to fill point with data

func (*Point) AddField

func (m *Point) AddField(k string, v interface{}) *Point

AddField adds a field to a point.

func (*Point) AddTag

func (m *Point) AddTag(k, v string) *Point

AddTag adds a tag to a point.

func (*Point) FieldList

func (m *Point) FieldList() []*lp.Field

FieldList returns a slice containing the fields of a Point.

func (*Point) Name

func (m *Point) Name() string

Name returns the name of measurement of a point.

func (*Point) SetTime

func (m *Point) SetTime(timestamp time.Time) *Point

SetTime set timestamp for a Point.

func (*Point) SortFields

func (m *Point) SortFields() *Point

SortFields orders the fields of a point alphanumerically by key.

func (*Point) SortTags

func (m *Point) SortTags() *Point

SortTags orders the tags of a point alphanumerically by key. This is just here as a helper, to make it easy to keep tags sorted if you are creating a Point manually.

func (*Point) TagList

func (m *Point) TagList() []*lp.Tag

TagList returns a slice containing tags of a Point.

func (*Point) Time

func (m *Point) Time() time.Time

Time is the timestamp of a Point.

Jump to

Keyboard shortcuts

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