lang

package
v0.99.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FluxCompilerType = "flux"
	ASTCompilerType  = "ast"
)

Variables

This section is empty.

Functions

func AddCompilerMappings

func AddCompilerMappings(mappings flux.CompilerMappings) error

AddCompilerMappings adds the Flux specific compiler mappings.

func HaveExecutionDependencies

func HaveExecutionDependencies(ctx context.Context) bool

func WalkIR

func WalkIR(ctx context.Context, astPkg *ast.Package, f func(o *flux.Operation) error) error

WalkIR applies the function `f` to each operation in the compiled spec. WARNING: this function evaluates the AST using an unlimited allocator. In case of dynamic queries this could lead to unexpected memory usage.

Types

type ASTCompiler

type ASTCompiler struct {
	AST *ast.Package `json:"ast"`
	Now time.Time
}

ASTCompiler implements Compiler by producing a Spec from an AST.

func (ASTCompiler) Compile

func (c ASTCompiler) Compile(ctx context.Context) (flux.Program, error)

func (ASTCompiler) CompilerType

func (ASTCompiler) CompilerType() flux.CompilerType

func (*ASTCompiler) PrependFile

func (c *ASTCompiler) PrependFile(file *ast.File)

PrependFile prepends a file onto the compiler's list of package files.

type AstProgram

type AstProgram struct {
	*Program

	Ast *ast.Package
	Now time.Time
}

AstProgram wraps a Program with an AST that will be evaluated upon Start. As such, the PlanSpec is populated after Start and evaluation errors are returned by Start.

func Compile

func Compile(q string, now time.Time, opts ...CompileOption) (*AstProgram, error)

Compile evaluates a Flux script producing a flux.Program. now parameter must be non-zero, that is the default now time should be set before compiling.

func CompileAST

func CompileAST(astPkg *ast.Package, now time.Time, opts ...CompileOption) *AstProgram

CompileAST evaluates a Flux AST and produces a flux.Program. now parameter must be non-zero, that is the default now time should be set before compiling.

func (*AstProgram) Start

func (p *AstProgram) Start(ctx context.Context, alloc *memory.Allocator) (flux.Query, error)

type CompileOption

type CompileOption func(*compileOptions)

CompileOption represents an option for compilation.

func Verbose

func Verbose(v bool) CompileOption

func WithExtern

func WithExtern(extern *ast.File) CompileOption

func WithLogPlanOpts

func WithLogPlanOpts(lopts ...plan.LogicalOption) CompileOption

func WithPhysPlanOpts

func WithPhysPlanOpts(popts ...plan.PhysicalOption) CompileOption

type ExecutionDependencies

type ExecutionDependencies struct {
	Allocator *memory.Allocator
	Logger    *zap.Logger
}

ExecutionDependencies represents the dependencies that a function call executed by the Interpreter needs in order to trigger the execution of a flux.Program

func GetExecutionDependencies

func GetExecutionDependencies(ctx context.Context) ExecutionDependencies

func (ExecutionDependencies) Inject

type FluxCompiler

type FluxCompiler struct {
	Now    time.Time
	Extern *ast.File `json:"extern"`
	Query  string    `json:"query"`
}

FluxCompiler compiles a Flux script into a spec.

func (FluxCompiler) Compile

func (c FluxCompiler) Compile(ctx context.Context) (flux.Program, error)

func (FluxCompiler) CompilerType

func (c FluxCompiler) CompilerType() flux.CompilerType

type LoggingProgram

type LoggingProgram interface {
	SetLogger(logger *zap.Logger)
}

type Program

type Program struct {
	Logger   *zap.Logger
	PlanSpec *plan.Spec
	// contains filtered or unexported fields
}

Program implements the flux.Program interface. It will execute a compiled plan using an executor.

func CompileTableObject

func CompileTableObject(ctx context.Context, to *flux.TableObject, now time.Time, opts ...CompileOption) (*Program, error)

CompileTableObject evaluates a TableObject and produces a flux.Program. now parameter must be non-zero, that is the default now time should be set before compiling.

func (*Program) SetLogger

func (p *Program) SetLogger(logger *zap.Logger)

func (*Program) Start

func (p *Program) Start(ctx context.Context, alloc *memory.Allocator) (flux.Query, error)

type TableObjectCompiler

type TableObjectCompiler struct {
	Tables *flux.TableObject
	Now    time.Time
}

TableObjectCompiler compiles a TableObject into an executable flux.Program. It is not added to CompilerMappings and it is not serializable, because it is impossible to use it outside of the context of an ongoing execution.

func (*TableObjectCompiler) Compile

func (c *TableObjectCompiler) Compile(ctx context.Context) (flux.Program, error)

func (*TableObjectCompiler) CompilerType

func (*TableObjectCompiler) CompilerType() flux.CompilerType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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