Documentation ¶
Index ¶
- Constants
- func QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
- func WideToMany(frame *data.Frame) ([]mathexp.Series, error)
- type CMDNode
- type Command
- type CommandType
- type DSNode
- type DataPipeline
- type MathCommand
- type Node
- type NodeType
- type ReduceCommand
- type ResampleCommand
- type Service
- func (s *Service) BuildPipeline(req *backend.QueryDataRequest) (DataPipeline, error)
- func (s *Service) ExecutePipeline(ctx context.Context, pipeline DataPipeline) (*backend.QueryDataResponse, error)
- func (s *Service) TransformData(ctx context.Context, req *backend.QueryDataRequest) (r *backend.QueryDataResponse, err error)
- func (s *Service) WrapTransformData(ctx context.Context, query *tsdb.TsdbQuery) (*tsdb.Response, error)
Constants ¶
const DatasourceID = -100
DatasourceID is the fake datasource id used in requests to identify it as an expression command.
const DatasourceName = "__expr__"
DatasourceName is the string constant used as the datasource name in requests to identify it as an expression command.
const DatasourceUID = "-100"
DatasourceUID is the fake datasource uid used in requests to identify it as an expression command.
Variables ¶
This section is empty.
Functions ¶
func QueryData ¶
func QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
QueryData is called used to query datasources that are not expression commands, but are used alongside expressions and/or are the input of an expression command.
Types ¶
type CMDNode ¶
type CMDNode struct { CMDType CommandType Command Command // contains filtered or unexported fields }
CMDNode is a DPNode that holds an expression command.
func (*CMDNode) Execute ¶
Execute runs the node and adds the results to vars. If the node requires other nodes they must have already been executed and their results must already by in vars.
func (*CMDNode) ID ¶
func (b *CMDNode) ID() int64
ID returns the id of the node so it can fulfill the gonum's graph Node interface.
type Command ¶
type Command interface { NeedsVars() []string Execute(c context.Context, vars mathexp.Vars) (mathexp.Results, error) }
Command is an interface for all expression commands.
type CommandType ¶
type CommandType int
CommandType is the type of the expression command.
const ( // TypeUnknown is the CMDType for an unrecognized expression type. TypeUnknown CommandType = iota // TypeMath is the CMDType for a math expression. TypeMath // TypeReduce is the CMDType for a reduction expression. TypeReduce // TypeResample is the CMDType for a resampling expression. TypeResample // TypeClassicConditions is the CMDType for the classic condition operation. TypeClassicConditions )
func ParseCommandType ¶
func ParseCommandType(s string) (CommandType, error)
ParseCommandType returns a CommandType from its string representation.
func (CommandType) String ¶
func (gt CommandType) String() string
type DSNode ¶
type DSNode struct {
// contains filtered or unexported fields
}
DSNode is a DPNode that holds a datasource request.
func (*DSNode) Execute ¶
Execute runs the node and adds the results to vars. If the node requires other nodes they must have already been executed and their results must already by in vars.
func (*DSNode) ID ¶
func (b *DSNode) ID() int64
ID returns the id of the node so it can fulfill the gonum's graph Node interface.
type DataPipeline ¶
type DataPipeline []Node
DataPipeline is an ordered set of nodes returned from DPGraph processing.
type MathCommand ¶
type MathCommand struct { RawExpression string Expression *mathexp.Expr // contains filtered or unexported fields }
MathCommand is a command for a math expression such as "1 + $GA / 2"
func NewMathCommand ¶
func NewMathCommand(refID, expr string) (*MathCommand, error)
NewMathCommand creates a new MathCommand. It will return an error if there is an error parsing expr.
func UnmarshalMathCommand ¶
func UnmarshalMathCommand(rn *rawNode) (*MathCommand, error)
UnmarshalMathCommand creates a MathCommand from Grafarg's frontend query.
func (*MathCommand) Execute ¶
Execute runs the command and returns the results or an error if the command failed to execute.
func (*MathCommand) NeedsVars ¶
func (gm *MathCommand) NeedsVars() []string
NeedsVars returns the variable names (refIds) that are dependencies to execute the command and allows the command to fulfill the Command interface.
type Node ¶
type Node interface { ID() int64 // ID() allows the gonum graph node interface to be fulfilled NodeType() NodeType RefID() string Execute(c context.Context, vars mathexp.Vars) (mathexp.Results, error) String() string }
Node is a node in a Data Pipeline. Node is either a expression command or a datasource query.
type NodeType ¶
type NodeType int
NodeType is the type of a DPNode. Currently either a expression command or datasource query.
type ReduceCommand ¶
type ReduceCommand struct { Reducer string VarToReduce string // contains filtered or unexported fields }
ReduceCommand is an expression command for reduction of a timeseries such as a min, mean, or max.
func NewReduceCommand ¶
func NewReduceCommand(refID, reducer, varToReduce string) *ReduceCommand
NewReduceCommand creates a new ReduceCMD.
func UnmarshalReduceCommand ¶
func UnmarshalReduceCommand(rn *rawNode) (*ReduceCommand, error)
UnmarshalReduceCommand creates a MathCMD from Grafarg's frontend query.
func (*ReduceCommand) Execute ¶
Execute runs the command and returns the results or an error if the command failed to execute.
func (*ReduceCommand) NeedsVars ¶
func (gr *ReduceCommand) NeedsVars() []string
NeedsVars returns the variable names (refIds) that are dependencies to execute the command and allows the command to fulfill the Command interface.
type ResampleCommand ¶
type ResampleCommand struct { Window time.Duration VarToResample string Downsampler string Upsampler string TimeRange backend.TimeRange // contains filtered or unexported fields }
ResampleCommand is an expression command for resampling of a timeseries.
func NewResampleCommand ¶
func NewResampleCommand(refID, rawWindow, varToResample string, downsampler string, upsampler string, tr backend.TimeRange) (*ResampleCommand, error)
NewResampleCommand creates a new ResampleCMD.
func UnmarshalResampleCommand ¶
func UnmarshalResampleCommand(rn *rawNode) (*ResampleCommand, error)
UnmarshalResampleCommand creates a ResampleCMD from Grafarg's frontend query.
func (*ResampleCommand) Execute ¶
Execute runs the command and returns the results or an error if the command failed to execute.
func (*ResampleCommand) NeedsVars ¶
func (gr *ResampleCommand) NeedsVars() []string
NeedsVars returns the variable names (refIds) that are dependencies to execute the command and allows the command to fulfill the Command interface.
type Service ¶
Service is service representation for expression handling.
func (*Service) BuildPipeline ¶
func (s *Service) BuildPipeline(req *backend.QueryDataRequest) (DataPipeline, error)
BuildPipeline builds a pipeline from a request.
func (*Service) ExecutePipeline ¶
func (s *Service) ExecutePipeline(ctx context.Context, pipeline DataPipeline) (*backend.QueryDataResponse, error)
ExecutePipeline executes an expression pipeline and returns all the results.
func (*Service) TransformData ¶
func (s *Service) TransformData(ctx context.Context, req *backend.QueryDataRequest) (r *backend.QueryDataResponse, err error)
TransformData takes Queries which are either expressions nodes or are datasource requests.