Home Reference Source
public class | source

InfluxWriter

InfluxWriter batches points and writes them to influxdb.

Constructor Summary

Public Constructor
public

constructor(options: *)

Member Summary

Private Members
private

_batcher: module.Batcher

private

Influx will overwrite points using the same timestamp and tags.

private

_influx: InfluxDB

private

Method Summary

Public Methods
public

writePoint(measurement: string, tags: Record, fields: Record, time: undefined)

Add a point to the current batch.

Private Methods
private

async _flushBatch(batch: undefined): Promise

Flush a batch to InfluxDB.

Public Constructors

public constructor(options: *) source

Params:

NameTypeAttributeDescription
options *

Private Members

private _batcher: module.Batcher source

private _counter: number source

Influx will overwrite points using the same timestamp and tags. To work around this we use this _counter field as the nanosecond segment of the timestamp and increment it every time a point is written. This way it is extremely unlikely that any points are overwritten.

private _influx: InfluxDB source

private _tags: Object<String, String> source

Public Methods

public writePoint(measurement: string, tags: Record, fields: Record, time: undefined) source

Add a point to the current batch. If this batch has exceeded the maximum batch size it will be flushed.

Params:

NameTypeAttributeDescription
measurement string
tags Record
fields Record
time undefined

Private Methods

private async _flushBatch(batch: undefined): Promise source

Flush a batch to InfluxDB. This method is triggered by the 'flush' event from Batcher.

Params:

NameTypeAttributeDescription
batch undefined

Return:

Promise