influx

package
v0.0.0-...-aa2a11b Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultScalingInterval = 500 * time.Millisecond

DefaultScalingInterval represents default scaling interval(time to wait before a new writer is started/killed) used by BatchingWriter.

Variables

View Source
var DefaultInstanceLimit = uint(runtime.NumCPU())

DefaultInstanceLimit represents default limit on instances spawned by BatchingWriter.

Functions

This section is empty.

Types

type BatchPointsWriter

type BatchPointsWriter interface {
	Write(bp influxdb.BatchPoints) error
}

BatchPointsWriter writes influxdb.BatchPoints to Influx database.

type BatchingWriter

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

BatchingWriter is a PointWriter, which writes points in batches. BatchingWriter scales automatically once it notices a delay of scalingInterval to write a batch of points and downscales if no points are supplied to an instance for a duration of scalingInterval. BatchingWriter spawns an instance for each unique BatchPointsConfig specified and up to limit() additional instances on top of that. BatchingWriter does not limit the amount of instances if limit is nil. Maximum number of instances spawned is equal to amount of unique BatchPointsConfig passed plus value, specified by WithInstanceLimit option. By default, BatchingWriter does not limit amount of instances. Each instance is spawned in a separate goroutine.

func NewBatchingWriter

func NewBatchingWriter(log ttnlog.Interface, w BatchPointsWriter, opts ...BatchingWriterOption) *BatchingWriter

NewBatchingWriter creates new BatchingWriter. If WithScalingInterval is not specified, DefaultScalingInterval value is used. If WithInstanceLimit is not specified, DefaultInstanceLimit is used.

func (*BatchingWriter) Write

Write delegates p to a running instance of BatchingWriter and spawns new instances as required.

type BatchingWriterOption

type BatchingWriterOption func(w *BatchingWriter)

BatchingWriterOption is passed to the constructor of BatchingWriter to configure it accordingly

func WithInstanceLimit

func WithInstanceLimit(v uint) BatchingWriterOption

WithInstanceLimit sets a limit on amount of additional instances spawned by BatchingWriter

func WithScalingInterval

func WithScalingInterval(v time.Duration) BatchingWriterOption

WithInstanceLimit sets a limit on amount of additional instances spawned by BatchingWriter

type PointWriter

type PointWriter interface {
	Write(bpConf influxdb.BatchPointsConfig, p *influxdb.Point) error
}

PointWriter writes *influxdb.Point to Influx database.

type SinglePointWriter

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

SinglePointWriter is a PointWriter, which writes points one-by-one

func NewSinglePointWriter

func NewSinglePointWriter(log ttnlog.Interface, w BatchPointsWriter) *SinglePointWriter

NewSinglePointWriter creates new SinglePointWriter

func (*SinglePointWriter) Write

Write creates new influxdb.BatchPoints containing p and delegates that to the writer

Jump to

Keyboard shortcuts

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