command

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const LineBreak = "\n"

Variables

View Source
var CommandRunnerFactoryRegistry *commandRunnerFactoryRegistry

CommandRunnerFactoryRegistry is the global query engine factory registry

View Source
var (
	ErrDialectNotSupported = errors.New("dialect not support")
)

Functions

This section is empty.

Types

type Command

type Command struct {
	// Cmd is a raw query expression
	Cmd     string
	Dialect DialectType

	Database string
	// Start and End attributes are mainly used for PromQL currently
	// as it doesn't support time-bounding query expression itself
	Start      *time.Time
	End        *time.Time
	Timezone   *time.Location
	Evaluation *time.Time
	// Step is evaluation step for PromQL.
	// As InfluxQL doesn't have the equivalent expression or concept,
	// we use it as interval parameter for InfluxQL GROUP BY time(interval)
	// if the raw query doesn't contain PromQL MatrixSelector expression.
	// If the raw query does contain PromQL parser.MatrixSelector expression,
	// its Range attribute will be used as the interval parameter.
	Step time.Duration

	DataType DataType
	// ValueFieldKey indicates which field will be used.
	// As matrix value field as measurement in InfluxDB may contain multiple fields that is different from Prometheus,
	// so we may need to set ValueFieldKey.
	//
	// Default is “`value“` field.
	ValueFieldKey string
	// LabelName is only used for label values query.
	LabelName string
}

Command wraps a raw query expression with several related attributes

type CommandType

type CommandType struct {
	OperationType OperationType
	DialectType   DialectType
}

CommandType indicates the type of Command in business meaning

type DataType

type DataType int

DataType indicates a Command is for table display or for graph display in data visualization platform like Grafana Basically,

  • TABLE_DATA is for raw table data query
  • GRAPH_DATA is for time-bounding graph data query
  • LABEL_VALUES_DATA is for label values data query like fetching data for label selector options at the top of Grafana dashboard
const (
	TABLE_DATA DataType = iota + 1
	GRAPH_DATA
	LABEL_VALUES_DATA
)

type DialectType

type DialectType string

DialectType is alias of string type and indicates which query grammar a Command is using

type ICommandRunner

type ICommandRunner interface {
	Run(ctx context.Context, cmd Command) (interface{}, error)
}

ICommandRunner is an interface for query engine

type ICommandRunnerFactory

type ICommandRunnerFactory interface {
	Build(client influxdb.Client, cfg config.Config) ICommandRunner
}

ICommandRunnerFactory is an interface for query engine factory

type IReusableCommandRunner

type IReusableCommandRunner interface {
	ICommandRunner
	Recycle()
}

IReusableCommandRunner is an interface for query engine and supporting reuse itself

type OperationType

type OperationType int

OperationType indicates a Command is for writing or for querying

const (
	QUERY_OPERATION OperationType = iota + 1
	WRITE_OPERATION               = iota + 1
)

Jump to

Keyboard shortcuts

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