influxdb

package
v0.0.0-...-332c7e9 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package influxdb adds functions to interact with InfluxDB.

Index

Constants

View Source
const (
	// DefaultWriteTimeout is the default write timeout.
	DefaultWriteTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an InfluxDB client.

func (*Client) Close

func (c *Client) Close(ctx context.Context)

Close closes the client.

func (*Client) Query

func (c *Client) Query(ctx context.Context, query string) (map[time.Time]any, error)

func (*Client) Record

func (c *Client) Record(ctx context.Context, entry entry.Entry) error

Record implements Database. We use the non-blocking write API. This scales well but is also more prone to error.

type Config

type Config struct {
	NonBlockingWrites NonBlockingWrites `name:"non_blocking_writes"`
	Address           string            `name:"address" description:"server address"`
	Token             string            `name:"token" description:"auth token. Generate a random one using 'openssl rand -hex 32'"`
	Bucket            string            `name:"bucket" description:"data bucket"`
	Organization      string            `name:"organization" description:"organization"`
	WriteTimeout      time.Duration     `name:"write_timeout" description:"write timeout in seconds (for blocking writes)"`
	SetupOpts         SetupOptions      `name:"setup" description:"setup options"`
}

Config configures the InfluxDB client.

func (*Config) NewClient

func (c *Config) NewClient(ctx context.Context) *Client

New returns a new client. Use Close() to close the client after done.

func (Config) Setup

func (cfg Config) Setup(ctx context.Context) error

Setup sets up the database with the provided config. Use this function only on the first run and for testing.

type NonBlockingWrites

type NonBlockingWrites struct {
	Enabled       bool `name:"enabled" description:"enable non-blocking writes"`
	BatchSize     int  `name:"batch_size" description:"batch size"`
	FlushInterval int  `name:"flush_interval" description:"flush interval"`
}

NonBlockingWrites uses the non-blocking write API. This scales well but is also more prone to error. In case of a crash, data may be lost. If set to false (default), blocking write API is used, which is more reliable.

type SetupOptions

type SetupOptions struct {
	Username           string `name:"username" description:"username"`
	Password           string `name:"password" description:"password"`
	RetentionPeriodHrs int    `name:"retention_period_hrs" description:"retention period in hours"`
}

SetupOptions are used to setup the database.

Jump to

Keyboard shortcuts

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