db

package
v0.0.0-...-4f0bb4a Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DBNAME db name
	DBNAME = "influxdb"
	// DBAddr db addr
	DBAddr = "http://localhost:8086"
	// DBUsername  db username
	DBUsername = "test"
	// DBPassword db password
	DBPassword = "test123"
	// DBInitialSize ini pool size
	DBInitialSize int
	// DBMaxActive max active conn in pool
	DBMaxActive int
	// DBIdleTimetout the conn max idle time
	DBIdleTimetout time.Duration
)

Functions

func CloseConn

func CloseConn(conn client.Client) error

CloseConn release influxdb client conn

func GetConn

func GetConn() client.Client

GetConn get influxdb client conn

func Init

func Init()

Init init db

func Query

func Query(cmd string, precision string) (res []client.Result, err error)

Query with query and precision string

Types

type Condition

type Condition struct {
	Fields []string // columns for influxdb without index, separated by comma

	Measurement string // table name for influxdb

	// append time condition with and
	WhereExpressions []string

	// where time >= {startTime} and time <= {endTime}, format like 2015-08-18T00:00:00Z,
	// 2015-08-18 00:12:00, 1439856000000000000, 1439856000s, 24043524m,
	// now() - 30s, now() - 1m, now() - 1d, ...
	// UTC time
	StartTime string
	// format like startTime
	EndTime string

	// if timeSince set startTime and endTime will be disabled
	TimeSince string

	Intervals       string // required, default 30s ex: 5s, 5m, 5h..., group by time(5s)
	IntervalsOffset string // should be same unit for intervals, if exist will append intervals with comma

	// format like "host"  "email", if multi separated by comma
	// follows the group by ...
	Tags []string

	// fill options, in linear, none, null, previous
	// linear - Reports the results of linear interpolation for time intervals with no data.
	// none - Reports no timestamp and no value for time intervals with no data.
	// null -  Reports null for time intervals with no data but returns a timestamp. This is the same as the default behavior.
	// previous -   Reports the value from the previous time interval for time intervals with no data.
	// number
	// // follows the group by ...
	FillOption string

	// default is asc, you can use desc replace it
	OrderBy string

	Limit  int // LIMIT <N> returns the first N points from the specified measurement.
	Offset int // OFFSET <N> paginates N points in the query results.

	SLimit  int // SLIMIT <N> returns every point from <N> series in the specified measurement.
	SOffset int // SOFFSET <N> paginates N series in the query results.

	TimeZone string // default use UTC
}

Condition metrics condition for db ops

type Config

type Config struct {
	// NAME db name
	NAME string
	// Addr db addr
	Addr string
	// Username  db username
	Username string
	// Password db password
	Password string
	// InitialSize ini pool size
	InitialSize int
	// MaxActive max active conn in pool
	MaxActive int
	// IdleTimetout the conn max idle time
	IdleTimetout time.Duration
}

Config config the api

type Connection

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

Connection to a remote InfluxDB server.

type DB

type DB interface {
	// query data from db
	Query() (res interface{}, err error)
}

DB service for database

Directories

Path Synopsis
query

Jump to

Keyboard shortcuts

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