runtime

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 11 Imported by: 7

Documentation

Overview

Package runtime provide a runtime for the pipeline

Index

Constants

View Source
const (
	RegR0 = iota
	RegR1
	RegR2
	RegR3
	RegR4
	RegR5
)
View Source
const (
	PlRunInfoField = "pl_msg"
)

Variables

View Source
var (
	ErrNilKey           = errors.New("key is nil")
	ErrKeyNotComparable = errors.New("key is not comparable")
	ErrKeyExists        = errors.New("key exists")
)
View Source
var DenormalizedGlobalPatterns map[string]*grok.GrokPattern = grok.CopyDenormalizedDefalutPatterns()

Functions

func CastToStringE

func CastToStringE(val any, dtype ast.DType) (string, error)

func Conv2String

func Conv2String(v any, dtype ast.DType) (string, error)

func NewRunError

func NewRunError(ctx *Task, err string, pos token.LnColPos) *errchain.PlError

func PutContext

func PutContext(ctx *Task)

func RunArithmeticExpr

func RunArithmeticExpr(ctx *Task, expr *ast.ArithmeticExpr) (any, ast.DType, *errchain.PlError)

func RunArithmeticExprCheck

func RunArithmeticExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ArithmeticExpr) *errchain.PlError

func RunAssignmentExpr

func RunAssignmentExpr(ctx *Task, expr *ast.AssignmentExpr) (any, ast.DType, *errchain.PlError)

RunAssignmentExpr runs assignment expression, but actually it is a stmt

func RunAssignmentExprCheck

func RunAssignmentExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.AssignmentExpr) *errchain.PlError

func RunAttrExprCheck

func RunAttrExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.AttrExpr) *errchain.PlError

func RunBreakStmt

func RunBreakStmt(ctx *Task, stmt *ast.BreakStmt) (any, ast.DType, *errchain.PlError)

func RunBreakStmtCheck

func RunBreakStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.BreakStmt) *errchain.PlError

func RunCallExpr

func RunCallExpr(ctx *Task, expr *ast.CallExpr) (any, ast.DType, *errchain.PlError)

func RunCallExprCheck

func RunCallExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.CallExpr) *errchain.PlError

func RunConditionExpr

func RunConditionExpr(ctx *Task, expr *ast.ConditionalExpr) (any, ast.DType, *errchain.PlError)

func RunConditionExprCheck

func RunConditionExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ConditionalExpr) *errchain.PlError

func RunContinueStmt

func RunContinueStmt(ctx *Task, stmt *ast.ContinueStmt) (any, ast.DType, *errchain.PlError)

func RunContinueStmtCheck

func RunContinueStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.ContinueStmt) *errchain.PlError

func RunForInStmt

func RunForInStmt(ctx *Task, stmt *ast.ForInStmt) (any, ast.DType, *errchain.PlError)

func RunForInStmtCheck

func RunForInStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.ForInStmt) *errchain.PlError

func RunForStmt

func RunForStmt(ctx *Task, stmt *ast.ForStmt) (any, ast.DType, *errchain.PlError)

func RunForStmtCheck

func RunForStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.ForStmt) *errchain.PlError

func RunIfElseStmt

func RunIfElseStmt(ctx *Task, stmt *ast.IfelseStmt) (any, ast.DType, *errchain.PlError)

func RunIfElseStmtCheck

func RunIfElseStmtCheck(ctx *Task, ctxCheck *ContextCheck, stmt *ast.IfelseStmt) *errchain.PlError

func RunInExpr added in v0.2.5

func RunInExpr(ctx *Task, expr *ast.InExpr) (any, ast.DType, *errchain.PlError)

func RunIndexExprGet

func RunIndexExprGet(ctx *Task, expr *ast.IndexExpr) (any, ast.DType, *errchain.PlError)

func RunIndexExprGetCheck

func RunIndexExprGetCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.IndexExpr) *errchain.PlError

func RunListInitExpr

func RunListInitExpr(ctx *Task, expr *ast.ListLiteral) (any, ast.DType, *errchain.PlError)

func RunListInitExprCheck

func RunListInitExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ListLiteral) *errchain.PlError

func RunMapInitExpr

func RunMapInitExpr(ctx *Task, expr *ast.MapLiteral) (any, ast.DType, *errchain.PlError)

func RunMapInitExprCheck

func RunMapInitExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.MapLiteral) *errchain.PlError

func RunParenExpr

func RunParenExpr(ctx *Task, expr *ast.ParenExpr) (any, ast.DType, *errchain.PlError)

func RunParenExprCheck

func RunParenExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.ParenExpr) *errchain.PlError

func RunSliceExpr added in v0.3.0

func RunSliceExpr(ctx *Task, expr *ast.SliceExpr) (any, ast.DType, *errchain.PlError)

func RunSliceExprCheck added in v0.3.0

func RunSliceExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.SliceExpr) *errchain.PlError

func RunStmt

func RunStmt(ctx *Task, node *ast.Node) (any, ast.DType, *errchain.PlError)

RunStmt for all expr.

func RunStmtCheck

func RunStmtCheck(ctx *Task, ctxCheck *ContextCheck, node *ast.Node) *errchain.PlError

func RunStmts

func RunStmts(ctx *Task, nodes ast.Stmts) *errchain.PlError

func RunStmtsCheck

func RunStmtsCheck(ctx *Task, ctxCheck *ContextCheck, nodes ast.Stmts) *errchain.PlError

func RunUnaryExpr added in v0.2.6

func RunUnaryExpr(ctx *Task, expr *ast.UnaryExpr) (any, ast.DType, *errchain.PlError)

func RunUnaryExprCheck added in v0.2.8

func RunUnaryExprCheck(ctx *Task, ctxCheck *ContextCheck, expr *ast.UnaryExpr) *errchain.PlError

Types

type ContextCheck

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

type FuncCall

type FuncCall func(*Task, *ast.CallExpr) *errchain.PlError

type FuncCheck

type FuncCheck func(*Task, *ast.CallExpr) *errchain.PlError

type Input added in v0.3.0

type Input interface {
	Get(key string) (any, ast.DType, error)
}

type PlProcStack

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

func (*PlProcStack) Clear

func (stack *PlProcStack) Clear()

func (*PlProcStack) Get

func (stack *PlProcStack) Get(key string) (*Varb, error)

func (*PlProcStack) GetPattern

func (stack *PlProcStack) GetPattern(pattern string) (*grok.GrokPattern, bool)

func (*PlProcStack) Set

func (stack *PlProcStack) Set(key string, value any, dType ast.DType)

func (*PlProcStack) SetPattern

func (stack *PlProcStack) SetPattern(patternAlias string, grokPattern *grok.GrokPattern)

type PlReg

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

func (*PlReg) Count

func (reg *PlReg) Count() int

func (*PlReg) Get

func (reg *PlReg) Get(i PlRegRange) (any, ast.DType, error)

func (*PlReg) Reset

func (reg *PlReg) Reset()

func (*PlReg) ReturnAppend

func (reg *PlReg) ReturnAppend(val any, dtype ast.DType) bool

type PlRegRange

type PlRegRange uint

type Script

type Script struct {
	CallRef []*ast.CallExpr

	FuncCall map[string]FuncCall

	Name      string
	Namespace string
	Category  string
	FilePath  string

	Content string // deprecated

	Ast ast.Stmts
}

func (*Script) Check added in v0.3.0

func (s *Script) Check(funcsCheck map[string]FuncCheck) *errchain.PlError

func (*Script) RefRun added in v0.3.0

func (s *Script) RefRun(ctx *Task) *errchain.PlError

func (*Script) Run added in v0.3.0

func (s *Script) Run(data Input, signal Signal, fn ...TaskFn) *errchain.PlError

type Signal

type Signal interface {
	ExitSignal() bool
}

type Task added in v0.3.0

type Task struct {
	Regs PlReg
	// contains filtered or unexported fields
}

func GetContext

func GetContext() *Task

func InitCtx added in v0.3.0

func InitCtx(ctx *Task, input Input, script *Script, signal Signal) *Task

func InitCtxForCheck

func InitCtxForCheck(ctx *Task, script *Script, checkFn map[string]FuncCheck) *Task

func (*Task) GetFuncCall added in v0.3.0

func (ctx *Task) GetFuncCall(key string) (FuncCall, bool)

func (*Task) GetFuncCheck added in v0.3.0

func (ctx *Task) GetFuncCheck(key string) (FuncCheck, bool)

func (*Task) GetKey added in v0.3.0

func (ctx *Task) GetKey(key string) (*Varb, error)

func (*Task) GetKeyConv2Str added in v0.3.0

func (ctx *Task) GetKeyConv2Str(key string) (string, error)

func (*Task) GetPattern added in v0.3.0

func (ctx *Task) GetPattern(pattern string) (*grok.GrokPattern, bool)

func (*Task) InData added in v0.3.0

func (ctx *Task) InData() any

func (*Task) Name added in v0.3.0

func (ctx *Task) Name() string

func (*Task) ProcExit added in v0.3.0

func (ctx *Task) ProcExit() bool

func (*Task) SetCallRef added in v0.3.0

func (ctx *Task) SetCallRef(expr *ast.CallExpr)

func (*Task) SetExit added in v0.3.0

func (ctx *Task) SetExit()

func (*Task) SetPattern added in v0.3.0

func (ctx *Task) SetPattern(patternAlias string, gPattern *grok.GrokPattern)

func (*Task) SetVarb added in v0.3.0

func (ctx *Task) SetVarb(key string, value any, dtype ast.DType) error

func (*Task) Signal added in v0.3.0

func (ctx *Task) Signal() Signal

func (*Task) StackClear added in v0.3.0

func (ctx *Task) StackClear()

func (*Task) StackEnterNew added in v0.3.0

func (ctx *Task) StackEnterNew()

func (*Task) StackExitCur added in v0.3.0

func (ctx *Task) StackExitCur()

func (*Task) StmtRetrun added in v0.3.0

func (ctx *Task) StmtRetrun() bool

func (*Task) Val added in v0.3.0

func (ctx *Task) Val(key any) any

func (*Task) WithVal added in v0.3.0

func (ctx *Task) WithVal(key, val any, force bool) error

type TaskFn added in v0.3.0

type TaskFn func(ctx *Task)

func WithVal added in v0.3.0

func WithVal(key string, val any) TaskFn

type Varb

type Varb struct {
	Value any
	DType ast.DType
}

Jump to

Keyboard shortcuts

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