influxdb

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationMethod

type AuthenticationMethod int

AuthenticationMethod defines the type of authentication used.

const (
	NoAuthentication AuthenticationMethod = iota
	UserAuthentication
	BearerAuthentication
)

Supported authentication methods.

type BatchPoints

type BatchPoints interface {
	// AddPoint adds the given point to the Batch of points
	AddPoint(p Point)
	// AddPoints adds the given points to the Batch of points
	AddPoints(ps []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
}

BatchPointsConfig is the config data needed to create an instance of the BatchPoints struct

type Client

type Client interface {
	// Ping checks that status of cluster
	// The provided context can be used to cancel the request.
	Ping(ctx context.Context) (time.Duration, string, error)

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

	// Query makes an InfluxDB Query on the database.
	// The response is checked for an error and the is returned
	// if it exists
	Query(q Query) (*Response, error)
}

Client is an interface for writing to and querying from an InfluxDB instance.

type ClientCreator

type ClientCreator struct{}

Simple type to create github.com/influxdata/kapacitor/influxdb clients.

func (ClientCreator) Create

func (ClientCreator) Create(config Config) (ClientUpdater, error)

type ClientUpdater added in v1.1.0

type ClientUpdater interface {
	Client
	Update(new Config) error
	Close() error
}

type Config added in v1.1.0

type Config struct {
	// The URL of the InfluxDB server.
	URLs []string

	// Optional credentials for authenticating with the server.
	Credentials Credentials

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

	// Timeout for requests, defaults to no timeout.
	Timeout time.Duration

	// Transport is the HTTP transport to use for requests
	// If nil, a default transport will be used.
	Transport *http.Transport
}

HTTPConfig is the config data needed to create an HTTP Client

type Credentials

type Credentials struct {
	Method AuthenticationMethod

	Username string
	Password string

	Token string
}

Set of credentials depending on the authentication method

type HTTPClient

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

HTTPClient is safe for concurrent use.

func NewHTTPClient

func NewHTTPClient(conf Config) (*HTTPClient, error)

NewHTTPClient returns a new Client from the provided config. Client is safe for concurrent use by multiple goroutines.

func (*HTTPClient) Close

func (c *HTTPClient) Close() error

func (*HTTPClient) Ping

func (c *HTTPClient) Ping(ctx context.Context) (time.Duration, string, error)

Ping will check to see if the server is up with an optional timeout on waiting for leader. Ping returns how long the request took, the version of the server it connected to, and an error if one occurred.

func (*HTTPClient) Query

func (c *HTTPClient) Query(q Query) (*Response, error)

Query sends a command to the server and returns the Response

func (*HTTPClient) Update added in v1.1.0

func (c *HTTPClient) Update(new Config) error

UpdateURLs updates the running list of URLs.

func (*HTTPClient) Write

func (c *HTTPClient) Write(bp BatchPoints) error

type Message

type Message struct {
	Level string
	Text  string
}

Message represents a user message.

type Point

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

func (Point) Bytes

func (p Point) Bytes(precision string) []byte

Returns byte array of a line protocol representation of the point

type Query

type Query struct {
	Command   string
	Database  string
	Precision string
}

Query defines a query to send to the server

type Response

type Response struct {
	Results []Result
	Err     string `json:"error,omitempty"`
}

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   []imodels.Row
	Messages []*Message
	Err      string `json:"error,omitempty"`
}

Result represents a resultset returned from a single statement.

Jump to

Keyboard shortcuts

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