goinflux

package module
v0.0.0-...-a114fd0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

goinflux

Build Status GoDoc Go Report Card FOSSA Status

Golang ORM helper for influx database.

Examples

Open HTTP influx client:

client := goinflux.NewHTTPClient("http://localhost:8086", "", "")
err := client.Open()
if err != nil {
	log.Error(err)
}

Create compatible struct:

type Foo struct {
	Time       int64   `influx:"time"`
	Name       string  `influx:"name"`
	FloatValue float64 `influx:"float_value"`
	IntValue   int64   `influx:"int_value"`
	BoolValue  bool    `influx:"bool_value"`
}

Insert data to database:

var data []Foo
.
.
.
err := client.WriteQuery("EXAMPLE", "examples", "ms", "", data)

Read data from database:

var data []Foo
err := client.ReadQuery("SELECT * FROM examples", "EXAMPLE", "ms", nil).As(&data)

Execute query with parameters:

var data []Foo
params := make(map[string]interface{})
params["name"] = "foo"
err := client.ReadQuery("SELECT * FROM examples WHERE name=$name", "EXAMPLE", "ms", params).As(&data)

Helper exposes influxdb-client as well so it is possible to use features from standard influx library. For example:

client.Client.Query("SELECT * FROM examples")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InfluxHTTPClient

type InfluxHTTPClient struct {
	Client client.Client
	// contains filtered or unexported fields
}

InfluxHTTPClient is a http client to influxdb

func NewHTTPClient

func NewHTTPClient(address, username, password string) InfluxHTTPClient

NewHTTPClient creates new InfluxHTTPClient

func (InfluxHTTPClient) InsertRaw

func (ic InfluxHTTPClient) InsertRaw(db, precision, retentionPolicy string, points []*client.Point) error

InsertRaw insert raw influx client points to database

func (*InfluxHTTPClient) Open

func (ic *InfluxHTTPClient) Open() error

Open sets up influxdb http client

func (InfluxHTTPClient) ReadQuery

func (ic InfluxHTTPClient) ReadQuery(query, db, precission string, parameters map[string]interface{}) *RawResponse

ReadQuery performs read operation on influxdb

func (InfluxHTTPClient) WriteQuery

func (ic InfluxHTTPClient) WriteQuery(db, measurement, precision, retentionPolicy string, points interface{}) error

WriteQuery inserts points to influxdb

type RawResponse

type RawResponse struct {
	*client.Response
	Err error
}

RawResponse contains raw influxdb data returned by http client

func (RawResponse) As

func (rr RawResponse) As(v interface{}) error

As parses raw influx response to value pointed by v

Jump to

Keyboard shortcuts

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