influxlib

package
v0.0.0-...-a8d7af0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP = "HTTP"
	UDP  = "UDP"
)

Connection type.

Variables

This section is empty.

Functions

func GetTestBuffer

func GetTestBuffer(con *InfluxDBConnection) (string, error)

GetTestBuffer returns the string that would normally be written to influx DB

Types

type InfluxConfig

type InfluxConfig struct {
	Hostname        string
	Port            uint16
	Protocol        string
	Database        string
	RetentionPolicy string
}

InfluxConfig is a configuration struct for influxlib.

type InfluxDBConnection

type InfluxDBConnection struct {
	Client influxdb.Client
	Config *InfluxConfig
}

InfluxDBConnection is an object that the wrapper uses. Holds a client of the type v2.Client and the configuration

func Connect

func Connect(config *InfluxConfig) (*InfluxDBConnection, error)

Connect takes an InfluxConfig and establishes a connection to InfluxDB. It returns an InfluxDBConnection structure. InfluxConfig may be nil for a default connection.

func NewMockConnection

func NewMockConnection() (*InfluxDBConnection, error)

NewMockConnection returns an influxDBConnection with a "fake" client for offline testing.

func (*InfluxDBConnection) Close

func (conn *InfluxDBConnection) Close()

Close closes the connection opened by Connect()

func (*InfluxDBConnection) Query

func (conn *InfluxDBConnection) Query(query string) ([]Row, error)

Query sends a query to the influxCli and returns a slice of rows. Rows are of type map[string]interface{}

func (*InfluxDBConnection) RecordBatchPoints

func (conn *InfluxDBConnection) RecordBatchPoints(points []Point) error

RecordBatchPoints takes in a slice of influxlib.Point and writes them to the database.

func (*InfluxDBConnection) RecordPoint

func (conn *InfluxDBConnection) RecordPoint(p Point) error

RecordPoint implements the same as WritePoint but used a point struct as the argument instead.

func (*InfluxDBConnection) WritePoint

func (conn *InfluxDBConnection) WritePoint(measurement string,
	tags map[string]string, fields map[string]interface{}) error

WritePoint stores a datapoint to the database. Measurement:

The measurement to write to

Tags:

A dictionary of tags in the form string=string

Fields:

A dictionary of fields(keys) with their associated values

type Point

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

Point represents a datapoint to be written. Measurement:

The measurement to write to

Tags:

A dictionary of tags in the form string=string

Fields:

A dictionary of fields(keys) with their associated values

type Row

type Row map[string]interface{}

Row is defined as a map where the key (string) is the name of the column (field name) and the value is left as an interface to accept any value.

Jump to

Keyboard shortcuts

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