client

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2016 License: MIT, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UDPPayloadSize = 512
)

UDPPayloadSize is a reasonable default payload size for UDP packets that could be travelling over the internet.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchPoints

type BatchPoints interface {
	// AddPoint adds the given point to the Batch of points
	AddPoint(p *Point)
	// Points lists the points in the Batch
	Points() []*Point

	// Precision returns the currently set precision of this Batch
	Precision() string
	// SetPrecision sets the precision of this batch.
	SetPrecision(s string) error

	// Database returns the currently set database of this Batch
	Database() string
	// SetDatabase sets the database of this Batch
	SetDatabase(s string)

	// WriteConsistency returns the currently set write consistency of this Batch
	WriteConsistency() string
	// SetWriteConsistency sets the write consistency of this Batch
	SetWriteConsistency(s string)

	// RetentionPolicy returns the currently set retention policy of this Batch
	RetentionPolicy() string
	// SetRetentionPolicy sets the retention policy of this Batch
	SetRetentionPolicy(s string)
}

BatchPoints is an interface into a batched grouping of points to write into InfluxDB together. BatchPoints is NOT thread-safe, you must create a separate batch for each goroutine.

func NewBatchPoints

func NewBatchPoints(conf BatchPointsConfig) (BatchPoints, error)

NewBatchPoints returns a BatchPoints interface based on the given config.

type BatchPointsConfig

type BatchPointsConfig struct {
	// Precision is the write precision of the points, defaults to "ns"
	Precision string

	// Database is the database to write points to
	Database string

	// RetentionPolicy is the retention policy of the points
	RetentionPolicy string

	// Write consistency is the number of servers required to confirm write
	WriteConsistency string
}

type Client

type Client interface {
	// Write takes a BatchPoints object and writes all Points to InfluxDB.
	Write(bp BatchPoints) error

	// Query makes an InfluxDB Query on the database. This will fail if using
	// the UDP client.
	Query(q Query) (*Response, error)

	// Close releases any resources a Client may be using.
	Close() error
}

Client is a client interface for writing & querying the database

func NewHTTPClient

func NewHTTPClient(conf HTTPConfig) (Client, error)

NewClient creates a client interface from the given config.

func NewUDPClient

func NewUDPClient(conf UDPConfig) (Client, error)

NewUDPClient returns a client interface for writing to an InfluxDB UDP service from the given config.

type HTTPConfig

type HTTPConfig struct {
	// Addr should be of the form "http://host:port"
	// or "http://[ipv6-host%zone]:port".
	Addr string

	// Username is the influxdb username, optional
	Username string

	// Password is the influxdb password, optional
	Password string

	// UserAgent is the http User Agent, defaults to "InfluxDBClient"
	UserAgent string

	// Timeout for influxdb writes, defaults to no timeout
	Timeout time.Duration

	// InsecureSkipVerify gets passed to the http client, if true, it will
	// skip https certificate verification. Defaults to false
	InsecureSkipVerify bool
}

type Point

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

func NewPoint

func NewPoint(
	name string,
	tags map[string]string,
	fields map[string]interface{},
	t ...time.Time,
) (*Point, error)

NewPoint returns a point with the given timestamp. If a timestamp is not given, then data is sent to the database without a timestamp, in which case the server will assign local time upon reception. NOTE: it is recommended to send data without a timestamp.

func (*Point) Fields

func (p *Point) Fields() map[string]interface{}

Fields returns the fields for the point

func (*Point) Name

func (p *Point) Name() string

Name returns the measurement name of the point

func (*Point) PrecisionString

func (p *Point) PrecisionString(precison string) string

PrecisionString returns a line-protocol string of the Point, at precision

func (*Point) String

func (p *Point) String() string

String returns a line-protocol string of the Point

func (*Point) Tags

func (p *Point) Tags() map[string]string

Name returns the tags associated with the point

func (*Point) Time

func (p *Point) Time() time.Time

Time return the timestamp for the point

func (*Point) UnixNano

func (p *Point) UnixNano() int64

UnixNano returns the unix nano time of the point

type Query

type Query struct {
	Command   string
	Database  string
	Precision string
}

Query defines a query to send to the server

func NewQuery

func NewQuery(command, database, precision string) Query

NewQuery returns a query object database and precision strings can be empty strings if they are not needed for the query.

type Response

type Response struct {
	Results []Result
	Err     error
}

Response represents a list of statement results.

func (*Response) Error

func (r *Response) Error() error

Error returns the first error from any statement. Returns nil if no errors occurred on any statements.

type Result

type Result struct {
	Series []models.Row
	Err    error
}

Result represents a resultset returned from a single statement.

type UDPConfig

type UDPConfig struct {
	// Addr should be of the form "host:port"
	// or "[ipv6-host%zone]:port".
	Addr string

	// PayloadSize is the maximum size of a UDP client message, optional
	// Tune this based on your network. Defaults to UDPBufferSize.
	PayloadSize int
}

Jump to

Keyboard shortcuts

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