expr

package
v0.0.0-...-0f8ae5d Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResolvingTimeout = time.Duration(100) * time.Millisecond
)

Variables

View Source
var (
	ErrTimeOut      = errors.New("expression resolver timed out")
	DefaultResolver = NewJavascriptExpressionParser()
)
View Source
var BuiltinFunctions = map[string]Function{
	"uid":           &UidFn{},
	"input":         &InputFn{},
	"output":        &OutputFn{},
	"param":         &ParamFn{},
	"task":          &TaskFn{},
	"outputHeaders": &OutputHeadersFn{},
}

Built-in functions for the expression parser

View Source
var (
	ErrMergeTypeMismatch = errors.New("cannot merge incompatible types")
)

Functions

func DeepCopy

func DeepCopy(i interface{}) interface{}

func Resolve

func Resolve(rootScope interface{}, currentTask string, expr *typedvalues.TypedValue) (*typedvalues.TypedValue, error)

Types

type DeepCopier

type DeepCopier interface {
	DeepCopy() DeepCopier
}

type Function

type Function interface {
	Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value
}

Function is an interface for providing functions that are able to be injected into the Otto runtime.

type InputFn

type InputFn struct{}

InputFn provides a function to get the input of a task for the given key. If no key is provided, the default key is used.

func (*InputFn) Apply

func (qf *InputFn) Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value

Apply gets the input of a task for the given key. If no key is provided, the default key is used. If no argument is provided at all, the default key of the current task will be used.

type InvocationScope

type InvocationScope struct {
	*ObjectMetadata
	Inputs map[string]interface{}
}

InvocationScope object provides information about the current invocation.

func (*InvocationScope) DeepCopy

func (s *InvocationScope) DeepCopy() DeepCopier

type JavascriptExpressionParser

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

func NewJavascriptExpressionParser

func NewJavascriptExpressionParser() *JavascriptExpressionParser

func (*JavascriptExpressionParser) Resolve

func (oe *JavascriptExpressionParser) Resolve(rootScope interface{}, currentTask string,
	expr *typedvalues.TypedValue) (*typedvalues.TypedValue, error)

type ObjectMetadata

type ObjectMetadata struct {
	Id        string
	CreatedAt int64 // unix timestamp
}

ObjectMetadata contains identity and meta-data about an object.

func (*ObjectMetadata) DeepCopy

func (s *ObjectMetadata) DeepCopy() DeepCopier

type OutputFn

type OutputFn struct{}

OutputFn provides a function to Get the output of a task.

func (*OutputFn) Apply

func (qf *OutputFn) Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value

Apply gets the output of a task. If no argument is provided the output of the current task is returned.

type OutputHeadersFn

type OutputHeadersFn struct{}

OutputHeadersFn provides a function to Get headers in the output of a task.

func (*OutputHeadersFn) Apply

func (qf *OutputHeadersFn) Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value

Apply gets headers in the output of a task. If no argument is provided the output of the current task is returned.

type ParamFn

type ParamFn struct{}

ParmFn provides a function to get the invocation param for the given key. If no key is provided, the default key is used.

func (*ParamFn) Apply

func (qf *ParamFn) Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value

Apply gets the invocation param for the given key. If no key is provided, the default key is used.

type Resolver

type Resolver interface {
	Resolve(rootScope interface{}, currentTask string, expr *typedvalues.TypedValue) (*typedvalues.TypedValue, error)
}

resolver resolves an expression within a given context/scope.

type Scope

type Scope struct {
	Workflow   *WorkflowScope
	Invocation *InvocationScope
	Tasks      Tasks
}

Scope is the broadest view of the workflow invocation, which can be queried by the user.

func NewScope

func NewScope(base *Scope, wfi *types.WorkflowInvocation) (*Scope, error)

NewScope creates a new scope given the workflow invocation and its associates workflow definition.

func (*Scope) DeepCopy

func (s *Scope) DeepCopy() DeepCopier

type Store

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

TODO Keep old states (but prune if OOM) TODO provide garbage collector

func NewStore

func NewStore() *Store

func (*Store) Delete

func (rs *Store) Delete(id string)

func (*Store) Get

func (rs *Store) Get(id string) (*Scope, bool)

func (*Store) Range

func (rs *Store) Range(fn func(key string, value *Scope) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (*Store) Set

func (rs *Store) Set(id string, data *Scope)

func (*Store) Update

func (rs *Store) Update(id string, updater func(entry *Scope) *Scope)

type TaskFn

type TaskFn struct{}

TaskFn provides a function to get a task for the given taskId. If no argument is provided the current task is returned.

func (*TaskFn) Apply

func (qf *TaskFn) Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value

Apply gets the task for the given taskId. If no argument is provided the current task is returned.

type TaskScope

type TaskScope struct {
	*ObjectMetadata
	Status        string // TaskInvocation status
	UpdatedAt     int64  // unix timestamp
	Inputs        map[string]interface{}
	Requires      map[string]*types.TaskDependencyParameters
	Output        interface{}
	OutputHeaders interface{}
	Function      string
}

TaskScope holds information about a specific task execution within the current workflow invocation.

func (*TaskScope) DeepCopy

func (s *TaskScope) DeepCopy() DeepCopier

type Tasks

type Tasks map[string]*TaskScope

func (Tasks) DeepCopy

func (s Tasks) DeepCopy() DeepCopier

type UidFn

type UidFn struct{}

UidFn provides a function to generate a unique (string) id

func (*UidFn) Apply

func (qf *UidFn) Apply(vm *otto.Otto, call otto.FunctionCall) otto.Value

Apply generates a unique (string) id

type WorkflowScope

type WorkflowScope struct {
	*ObjectMetadata
	UpdatedAt int64  // unix timestamp
	Status    string // workflow status
	Name      string
	Internal  bool
}

WorkflowScope provides information about the workflow definition.

func (*WorkflowScope) DeepCopy

func (s *WorkflowScope) DeepCopy() DeepCopier

Jump to

Keyboard shortcuts

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