gelpoc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WideToMany

func WideToMany(frame *data.Frame) ([]mathexp.Series, error)

WideToMany converts a data package wide type Frame to one or multiple Series. A series is created for each value type column of wide frame.

This might not be a good idea long term, but works now as an adapter/shim.

Types

type Command

type Command interface {
	NeedsVars() []string
	Execute(c context.Context, vars mathexp.Vars) (mathexp.Results, error)
}

Command is an interface for all GEL commands.

type CommandType

type CommandType int

CommandType is the type of GelCommand.

const (
	// TypeUnknown is the CMDType for an unrecognized GEL type.
	TypeUnknown CommandType = iota
	// TypeMath is the CMDType for a GEL math expression.
	TypeMath
	// TypeReduce is the CMDType for a GEL reduction function.
	TypeReduce
	// TypeResample is the CMDType for a GEL resampling function.
	TypeResample
)

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

func (dn *DSNode) Execute(ctx context.Context, vars mathexp.Vars) (mathexp.Results, error)

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.

func (*DSNode) NodeType

func (dn *DSNode) NodeType() NodeType

NodeType returns the data pipeline node type.

func (*DSNode) RefID

func (b *DSNode) RefID() string

RefID returns the refId of the node.

func (*DSNode) String

func (b *DSNode) String() string

String returns a string representation of the node. In particular for %v formating in error messages.

type DataPipeline

type DataPipeline []Node

DataPipeline is an ordered set of nodes returned from DPGraph processing.

type GELNode

type GELNode struct {
	GELType    CommandType
	GELCommand Command
	// contains filtered or unexported fields
}

GELNode is a DPNode that holds a GEL command.

func (*GELNode) Execute

func (gn *GELNode) Execute(ctx context.Context, vars mathexp.Vars) (mathexp.Results, error)

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 (*GELNode) ID

func (b *GELNode) ID() int64

ID returns the id of the node so it can fulfill the gonum's graph Node interface.

func (*GELNode) NodeType

func (gn *GELNode) NodeType() NodeType

NodeType returns the data pipeline node type.

func (*GELNode) RefID

func (b *GELNode) RefID() string

RefID returns the refId of the node.

func (*GELNode) String

func (b *GELNode) String() string

String returns a string representation of the node. In particular for %v formating in error messages.

type MathCommand

type MathCommand struct {
	RawExpression string
	Expression    *mathexp.Expr
}

MathCommand is a GEL commad for a GEL math expression such as "1 + $GA / 2"

func NewMathCommand

func NewMathCommand(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 Grafana's frontend query.

func (*MathCommand) Execute

func (gm *MathCommand) Execute(ctx context.Context, vars mathexp.Vars) (mathexp.Results, error)

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 GEL command or a datasource query.

type NodeType

type NodeType int

NodeType is the type of a DPNode. Currently either a GEL or datasource query.

const (
	// TypeGELNode is a DPNode NodeType for GEL commands.
	TypeGELNode NodeType = iota
	// TypeDatasourceNode is a DPNode NodeType for datasource queries.
	TypeDatasourceNode
)

type ReduceCommand

type ReduceCommand struct {
	Reducer     string
	VarToReduce string
}

ReduceCommand is a GEL command for reduction of a timeseries such as a min, mean, or max.

func NewReduceCommand

func NewReduceCommand(reducer, varToReduce string) *ReduceCommand

NewReduceCommand creates a new ReduceCMD.

func UnmarshalReduceCommand

func UnmarshalReduceCommand(rn *rawNode) (*ReduceCommand, error)

UnmarshalReduceCommand creates a MathCMD from Grafana's frontend query.

func (*ReduceCommand) Execute

func (gr *ReduceCommand) Execute(ctx context.Context, vars mathexp.Vars) (mathexp.Results, error)

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 {
	Rule          string
	VarToResample string
	Downsampler   string
	Upsampler     string
	TimeRange     backend.TimeRange
}

ResampleCommand is a GEL command for resampling of a timeseries

func NewResampleCommand

func NewResampleCommand(rule, varToResample string, downsampler string, upsampler string, tr backend.TimeRange) *ResampleCommand

NewResampleCommand creates a new ResampleCMD.

func UnmarshalResampleCommand

func UnmarshalResampleCommand(rn *rawNode) (*ResampleCommand, error)

UnmarshalResampleCommand creates a ResampleCMD from Grafana's frontend query.

func (*ResampleCommand) Execute

func (gr *ResampleCommand) Execute(ctx context.Context, vars mathexp.Vars) (mathexp.Results, error)

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

type Service struct {
	CallBack backend.TransformDataCallBackHandler
}

Service is service representation for GEL.

func (*Service) BuildPipeline

func (s *Service) BuildPipeline(queries []backend.DataQuery) (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 a GEL data pipeline and returns all the results.

Jump to

Keyboard shortcuts

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