Documentation
¶
Overview ¶
Package iftool allows you to encode/decode InfluxDb data to/from Go structs -- similiar to JSON and MongoDb using Go struct field tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanQuery ¶
CleanQuery can be used to strip a query string of newline characters. Typically only used for debugging.
Types ¶
type Client ¶
type Client interface {
influxClient.Client
// UseDB sets the DB to use for Query, WritePoint, and WritePointTagsFields.
// This field must be set before WritePoint... calls.
UseDB(db string) Client
// UseMeasurement sets the measurement to use for WritePoint, and WritePointTagsFields.
// If this is not set, a struct field with named InfluxMeasurement is required
// in the write data. The data passed in this call has priority over data fields in
// writes.
UseMeasurement(measurement string) Client
// UseTimeField sets the time field to use for WritePoint, and WritePointTagsFields. This
// call is optional, and a data struct field with a `influx:"time"` tag can also be used.
UseTimeField(fieldName string) Client
// Query executes an InfluxDb query, and unpacks the result into the
// result data structure.
DecodeQuery(query string, result interface{}) error
// WritePoint is used to write arbitrary data into InfluxDb.
WritePoint(data interface{}) error
// WritePoint is used to write batches of arbitrary data into InfluxDb.
WritePoints(points []interface{}) error
// WritePointTagsFields is used to write a point specifying tags and fields.
WritePointTagsFields(tags map[string]string, fields map[string]interface{}, t time.Time) error
AddPointTagsFieldsToBP(bp influxClient.BatchPoints, tags map[string]string, fields map[string]interface{}, t time.Time) error
}
A Client represents an influxdbhelper influxClient connection to an InfluxDb server.
func NewClient ¶
NewClient returns a new influxdbhelper influxClient given a url, user, password, and precision strings.
url is typically something like: http://localhost:8086
precision can be ‘h’, ‘m’, ‘s’, ‘ms’, ‘u’, or ‘ns’ and is used during write operations.
func NewClientFromFile ¶
type ClientConfig ¶
type ClientConfig struct {
URL string `json:"url"`
Port int `json:"port"`
User string `json:"user"`
Password string `json:"password"`
Precision string `json:"precision"`
}
func (ClientConfig) NewClient ¶
func (c ClientConfig) NewClient() (Client, error)
type Error ¶
type Error struct {
Errors []string
}
Error implements the error interface and can represents multiple errors that occur in the course of a single decode.
func (*Error) WrappedErrors ¶
WrappedErrors implements the errwrap.Wrapper interface to make this return value more useful with the errwrap and go-multierror libraries.
type Measurement ¶
type Measurement = string
Measurement is a type that defines the influx db measurement.