Documentation ¶
Index ¶
- Constants
- func Capitalize(s string) string
- func ConvertTypeToAST(in reflect.Type) (reflect.Type, error)
- func ConvertValueToAST(in interface{}) (interface{}, error)
- func Debugf(format string, args ...interface{})
- func Define(group Group) func(name String, value interface{}) (Action, error)
- func Error(ctx ExecutionContext) error
- func Errorf(format string, args ...interface{})
- func EscapeControl(s string) string
- func Eval(ctx ExecutionContext, variable interface{}) (interface{}, error)
- func EvalBool(ctx ExecutionContext, in Expression) (bool, error)
- func EvalFromAST(ctx ExecutionContext, in interface{}) (interface{}, error)
- func EvalInt(ctx ExecutionContext, in Expression) (int, error)
- func EvalInto(ctx ExecutionContext, inRaw, out interface{}) error
- func EvalString(ctx ExecutionContext, in Expression) (string, error)
- func EvalStringVars(ctx ExecutionContext, in []Expression) ([]string, error)
- func ExpectBool(expr Expression) error
- func ExpectEnv(key string) (string, error)
- func ExpectEqualTypes(aType, bType interface{}) error
- func ExpectInt(expr Expression) error
- func ExpectString(expr Expression) error
- func ExpressionType(in interface{}) interface{}
- func FunctionName(i interface{}) string
- func GetField(v interface{}, name String, fields ...String) (interface{}, error)
- func ImportStructsIntoAST(l *LexScope, structs ...reflect.Type) error
- func Infof(format string, args ...interface{})
- func IsDir(dirPath string) bool
- func IsExit(event Event) bool
- func MarshalCode(ctx ExecutionContext, iface interface{}) ([]byte, error)
- func MultiCloser(closers ...io.Closer) *multiCloser
- func OriginalType(t reflect.Type) reflect.Type
- func PInt32(in int32) *int32
- func PInt64(in int64) *int64
- func SetError(ctx ExecutionContext, err error)
- func SetLog(ctx ExecutionContext, log Logger)
- func SetStruct(ctx ExecutionContext, v interface{})
- func StartsWithLower(v string) bool
- func StructName(t reflect.Type) string
- func StructPackageName(t reflect.Type) string
- func Var(group Group) func(name String, fields ...String) (interface{}, error)
- func Warningf(format string, args ...interface{})
- func Writer(logger Logger) io.WriteCloser
- func Zero(iface reflect.Value) reflect.Value
- func ZeroFromAST(in interface{}) (interface{}, error)
- type Action
- type Bool
- type BoolSlice
- type BoolVar
- type BoolVarFunc
- type Channel
- type CloserFunc
- type CodeError
- type CodeMarshaler
- type ContainsAction
- type Context
- type ContextConfig
- type ContextKey
- type ConvertedFunc
- type Converter
- type DeferAction
- type DefineAction
- type DuplicateChannel
- type Event
- type ExecutionContext
- type ExitEvent
- type Expression
- type ExpressionSlice
- type FSNotify
- type FSNotifyEvent
- type FanInChannel
- type FnCall
- type Function
- type GetEventFunc
- type Group
- type IDAction
- type IfAction
- func (s *IfAction) Eval(ctx ExecutionContext) (interface{}, error)
- func (s *IfAction) EvalWithScope(ctx ExecutionContext) (interface{}, error)
- func (p *IfAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
- func (s *IfAction) NewInstance(group Group) (Group, interface{})
- func (p *IfAction) Type() interface{}
- type Int
- type IntSlice
- type IntVar
- type IntVarFunc
- type LambdaFunction
- func (f *LambdaFunction) Call(scope ExecutionContext) (interface{}, error)
- func (f *LambdaFunction) Eval(ctx ExecutionContext) (interface{}, error)
- func (f *LambdaFunction) EvalWithScope(scope ExecutionContext) (interface{}, error)
- func (f *LambdaFunction) ExpectEqualTypes(i interface{}) error
- func (f *LambdaFunction) MarshalCode(ctx ExecutionContext) ([]byte, error)
- func (f *LambdaFunction) NewCall() (*LambdaFunctionCall, error)
- func (f *LambdaFunction) NewInstance(group Group) (Group, interface{})
- func (f *LambdaFunction) Type() interface{}
- type LambdaFunctionCall
- func (f *LambdaFunctionCall) CheckCall() error
- func (f *LambdaFunctionCall) Eval(ctx ExecutionContext) (interface{}, error)
- func (f *LambdaFunctionCall) EvalStatements(ctx ExecutionContext) ([]Action, error)
- func (f *LambdaFunctionCall) EvalWithScope(scope ExecutionContext) (interface{}, error)
- func (f *LambdaFunctionCall) LambdaType() (*LambdaFunction, error)
- func (f *LambdaFunctionCall) MarshalCode(ctx ExecutionContext) ([]byte, error)
- func (f *LambdaFunctionCall) Type() interface{}
- type LambdaParam
- type LexScope
- type LexicalScope
- type LocalExitEvent
- type Logger
- type Marshaler
- type NewDefine
- type NewIf
- type NewParallel
- type NewSequence
- type NewVarRef
- type NopAction
- type NopScope
- type OneshotChannel
- type OneshotEvent
- type ParallelAction
- type PipeNetConn
- func (nc *PipeNetConn) Close() error
- func (nc *PipeNetConn) LocalAddr() net.Addr
- func (nc *PipeNetConn) Read(buf []byte) (n int, e error)
- func (nc *PipeNetConn) RemoteAddr() net.Addr
- func (nc *PipeNetConn) SetDeadline(t time.Time) error
- func (nc *PipeNetConn) SetReadDeadline(t time.Time) error
- func (nc *PipeNetConn) SetWriteDeadline(t time.Time) error
- func (nc *PipeNetConn) Write(buf []byte) (n int, e error)
- type Process
- type RuntimeScope
- type ScopeAction
- type Script
- type SendAction
- type SequenceAction
- type ShellAction
- type Snippet
- type Spec
- type String
- type StringSlice
- type StringVar
- type StringVarFunc
- type StringsVar
- type SyncBuffer
- type Test
- type TickEvent
- type TickerChannel
- type TypeChecker
- type TypeConverter
- type Unquoter
- type VarRef
- type WrapContext
Constants ¶
const ( // KeyCurrentDir is a current directory KeyCurrentDir = ContextKey("current.dir") // KeyError is an error value KeyError = ContextKey("error") // KeyLog is a logger associated with this execution KeyLog = ContextKey("log") // KeyProc is a process name KeyProc = "proc" // KeyID is a unique identifier of the run KeyID = "id" // KeyForce is a name of the force CI KeyForce = "force" // KeyEvent is an event produced by watchers KeyEvent = "event" // Underscore is underscore symbol Underscore = "_" StringType = "string" IntType = "int" BoolType = "bool" )
const (
// HumanDateFormat is a user friendly date format
HumanDateFormat = "Jan _2 15:04 UTC"
)
Variables ¶
This section is empty.
Functions ¶
func Capitalize ¶
Capitalize returns a copy of the string with first rune converted to capital letter
func ConvertTypeToAST ¶
ConvertTypeToAST converts incoming type to the type understood by force interpreter
func ConvertValueToAST ¶
func ConvertValueToAST(in interface{}) (interface{}, error)
ConvertValueToAST converts value to the value of the force-compatible type
func Define ¶
Define defines a variable type and returns an action that sets the variable on the execution
func Error ¶
func Error(ctx ExecutionContext) error
Error is a helper function that finds and returns an error
func EscapeControl ¶
EscapeControl escapes all ANSI escape sequences from string and returns a string that is safe to print on the CLI. This is to ensure that malicious servers can not hide output. For more details, see:
func Eval ¶
func Eval(ctx ExecutionContext, variable interface{}) (interface{}, error)
Eval evaluates variable based on the execution context
func EvalBool ¶
func EvalBool(ctx ExecutionContext, in Expression) (bool, error)
EvalBool evaluates bool from var
func EvalFromAST ¶
func EvalFromAST(ctx ExecutionContext, in interface{}) (interface{}, error)
EvalFromAST returns a new instance of the original struct marshaled from converted object, returns error if the object was not converted into AST
func EvalInt ¶
func EvalInt(ctx ExecutionContext, in Expression) (int, error)
EvalInt evaluates int from var
func EvalInto ¶
func EvalInto(ctx ExecutionContext, inRaw, out interface{}) error
EvalInto evaluates variable in within the execution context into variable out
func EvalString ¶
func EvalString(ctx ExecutionContext, in Expression) (string, error)
EvalString evaluates string from var
func EvalStringVars ¶
func EvalStringVars(ctx ExecutionContext, in []Expression) ([]string, error)
EvalStringVars evaluates string vars and returns a slice of strings
func ExpectBool ¶
func ExpectBool(expr Expression) error
ExpectBool returns nil if expression is bool, error otherwise
func ExpectEqualTypes ¶
func ExpectEqualTypes(aType, bType interface{}) error
ExpectEqualTypes compares expression types
func ExpectInt ¶
func ExpectInt(expr Expression) error
ExpectInt returns nil if expression is int, error otherwise
func ExpectString ¶
func ExpectString(expr Expression) error
ExpectString returns nil if expression is bool, error otherwise
func ExpressionType ¶
func ExpressionType(in interface{}) interface{}
ExpressionType returns a type evaluated by expression
func ImportStructsIntoAST ¶
ImportStructsIntoAST converts structs to AST compatible types and registers definitions in the
func MarshalCode ¶
func MarshalCode(ctx ExecutionContext, iface interface{}) ([]byte, error)
MarshalCode marshals parsed types into representation that could be interpreted by Force interpreter
func MultiCloser ¶
MultiCloser implements io.Close, it sequentially calls Close() on each object
func OriginalType ¶
OriginalType is original struct type
func SetError ¶
func SetError(ctx ExecutionContext, err error)
SetError is a helper function that adds an error to the context
func SetLog ¶
func SetLog(ctx ExecutionContext, log Logger)
SetLog adds a logger to the exectuion context
func SetStruct ¶
func SetStruct(ctx ExecutionContext, v interface{})
SetStruct sets struct from the value
func StartsWithLower ¶
StartsWithLower returns true if the string starts with lower case
func StructPackageName ¶
StructPackageName returns originating package name of this struct
func Writer ¶
func Writer(logger Logger) io.WriteCloser
Writer returns a writer that ouptuts everything to logger
func ZeroFromAST ¶
func ZeroFromAST(in interface{}) (interface{}, error)
ZeroFromAST returns zero value original struct from AST
Types ¶
type Action ¶
type Action interface { Expression }
Action is an expression with or without side effects
type Bool ¶
type Bool bool
Bool is a constant bool var
func (Bool) Eval ¶
func (b Bool) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates variable and returns bool
func (Bool) MarshalCode ¶
func (b Bool) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals the variable to code representation
type BoolSlice ¶
type BoolSlice []Expression
BoolSlice represents a slice of integers
func (BoolSlice) Eval ¶
func (s BoolSlice) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates a list of var references to types
func (BoolSlice) MarshalCode ¶
func (s BoolSlice) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode
type BoolVar ¶
type BoolVar struct {
Expression
}
func (BoolVar) Eval ¶
func (b BoolVar) Eval(ctx ExecutionContext) (interface{}, error)
type BoolVarFunc ¶
type BoolVarFunc func(ctx ExecutionContext) (interface{}, error)
BoolVarFunc wraps function and returns an interface BoolVar
func (BoolVarFunc) Eval ¶
func (f BoolVarFunc) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates variable and returns bool
func (BoolVarFunc) Type ¶
func (f BoolVarFunc) Type() interface{}
type Channel ¶
type Channel interface { // CodeMarshaler allows to marshal action into code CodeMarshaler // Start starts the process Start(ctx context.Context) error Events() <-chan Event Done() <-chan struct{} }
Channel produces events
func Duplicate ¶
Duplicate creates a channel that sends the same event count times, used for testing purposes
type CloserFunc ¶
type CloserFunc func() error
CloserFunc wraps function to create io.Closer compatible type
type CodeMarshaler ¶
type CodeMarshaler interface { // MarshalCode marshals object to text representation MarshalCode(ctx ExecutionContext) ([]byte, error) }
CodeMarshaler marshals objects to code that could be interpreted later
type ContainsAction ¶
type ContainsAction struct {
// contains filtered or unexported fields
}
func (*ContainsAction) Eval ¶
func (c *ContainsAction) Eval(ctx ExecutionContext) (interface{}, error)
func (*ContainsAction) MarshalCode ¶
func (c *ContainsAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals the variable to code representation
func (*ContainsAction) Type ¶
func (c *ContainsAction) Type() interface{}
type Context ¶
type Context struct { *sync.RWMutex *RuntimeScope // contains filtered or unexported fields }
Context implements local execution context
func NewContext ¶
func NewContext(cfg ContextConfig) *Context
NewContext returns a new context wraping context
func (*Context) Deadline ¶
Deadline returns the time when work done on behalf of this context should be canceled. Deadline returns ok==false when no deadline is set. Successive calls to Deadline return the same results.
func (*Context) Done ¶
func (c *Context) Done() <-chan struct{}
Done returns channel that is closed when the context is closed
func (*Context) Err ¶
Err returns an error associated with the context If Done is not yet closed, Err returns nil. If Done is closed, Err returns a non-nil error explaining why: Canceled if the context was canceled or DeadlineExceeded if the context's deadline passed. After Err returns a non-nil error, successive calls to Err return the same error.
type ContextConfig ¶
type ContextConfig struct { // Parent is a context to wrap Parent ExecutionContext // Process is a process Process Process // Event is event Event Event // ID is an execution ID ID string }
ContextConfig sets up local context
type ContextKey ¶
type ContextKey string
ContextKey is a special type used to set force-related context value, is recommended by context package to use separate type for context values to prevent namespace clash
type ConvertedFunc ¶
type ConvertedFunc struct {
// contains filtered or unexported fields
}
ConvertedFunc holds converted function
func (*ConvertedFunc) Eval ¶
func (c *ConvertedFunc) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates function and returns string
func (*ConvertedFunc) MarshalCode ¶
func (c *ConvertedFunc) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals code
func (*ConvertedFunc) Type ¶
func (c *ConvertedFunc) Type() interface{}
type Converter ¶
type Converter interface {
Convert(i interface{}) (interface{}, error)
}
Converter converts one value into another or returns error
type DeferAction ¶
type DeferAction struct {
// contains filtered or unexported fields
}
DeferAction runs actions in defer
func (*DeferAction) Eval ¶
func (d *DeferAction) Eval(ctx ExecutionContext) (interface{}, error)
Run runs deferred action
func (*DeferAction) MarshalCode ¶
func (d *DeferAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
func (*DeferAction) Type ¶
func (d *DeferAction) Type() interface{}
type DefineAction ¶
type DefineAction struct {
// contains filtered or unexported fields
}
DefineAction defines a variable
func (*DefineAction) Eval ¶
func (p *DefineAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval defines a variable on the context and evaluates to the value
func (*DefineAction) MarshalCode ¶
func (p *DefineAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
func (*DefineAction) Type ¶
func (p *DefineAction) Type() interface{}
Type returns type evaluated by expression
type DuplicateChannel ¶
type DuplicateChannel struct {
// contains filtered or unexported fields
}
func (*DuplicateChannel) Done ¶
func (d *DuplicateChannel) Done() <-chan struct{}
func (*DuplicateChannel) Events ¶
func (d *DuplicateChannel) Events() <-chan Event
func (*DuplicateChannel) MarshalCode ¶
func (d *DuplicateChannel) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals channel to code
func (*DuplicateChannel) String ¶
func (d *DuplicateChannel) String() string
type Event ¶
type Event interface { // AddMetadata adds metadada to the execution context AddMetadata(ctx ExecutionContext) // Created returns time when the event was originated in the system Created() time.Time }
Event is generated by channel
func GetExitEventFromContext ¶
func GetExitEventFromContext(ctx ExecutionContext) Event
type ExecutionContext ¶
type ExecutionContext interface { context.Context // Event is an event that generated the action Event() Event // Process returns a process associated with context Process() Process // SetValue sets a key value pair of the context SetValue(key interface{}, value interface{}) error // ID is an execution unique identifier ID() string }
ExecutionContext represents an execution context of a certain action execution chain,
func EmptyContext ¶
func EmptyContext() ExecutionContext
EmptyContext returns empty execution context
type ExitEvent ¶
type ExitEvent interface {
ExitCode() int
}
ExitEvent is a special event tells the process group to exit with a specified code
type Expression ¶
type Expression interface { // CodeMarshaler allows to marshal action into code CodeMarshaler // Eval evaluates variable and returns result of the expression Eval(ctx ExecutionContext) (interface{}, error) // Type returns the type of the expression, // for concrete types it is a zero instance - // empty string or function, for higher level types // like lambda function, returns the value Type() interface{} }
Expression is any expression or variable that can be evaluated to contrete type
func Contains ¶
func Contains(slice, item Expression) (Expression, error)
Contains returns true if a sequence contains value
func Strings ¶
func Strings(args ...Expression) (Expression, error)
Strings returns a list of strings evaluated from the arguments
type ExpressionSlice ¶
type ExpressionSlice []Expression
ExpressionSlice is a wrapper around a slice of expressoins that adds interface method to evaluate to expression
func (ExpressionSlice) Eval ¶
func (s ExpressionSlice) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates a list of var references to types
func (ExpressionSlice) Type ¶
func (s ExpressionSlice) Type() interface{}
Type of slice of expressions
type FSNotify ¶
type FSNotify struct { Files []string // contains filtered or unexported fields }
func (*FSNotify) MarshalCode ¶
func (f *FSNotify) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals channel to code
type FSNotifyEvent ¶
func (*FSNotifyEvent) AddMetadata ¶
func (f *FSNotifyEvent) AddMetadata(ctx ExecutionContext)
func (*FSNotifyEvent) Created ¶
func (f *FSNotifyEvent) Created() time.Time
func (*FSNotifyEvent) String ¶
func (f *FSNotifyEvent) String() string
type FanInChannel ¶
type FanInChannel struct {
// contains filtered or unexported fields
}
FanInChannel
func (*FanInChannel) Done ¶
func (d *FanInChannel) Done() <-chan struct{}
func (*FanInChannel) Events ¶
func (d *FanInChannel) Events() <-chan Event
func (*FanInChannel) MarshalCode ¶
func (d *FanInChannel) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals channel to code
func (*FanInChannel) Start ¶
func (d *FanInChannel) Start(ctx context.Context) error
Start starts all sub channels and launches fan in and wait gorotouines
func (*FanInChannel) String ¶
func (d *FanInChannel) String() string
type FnCall ¶
type FnCall struct { // Package is a package name Package string // Fn is a function, the name will // be extracted from it Fn interface{} // FnName is a function name, will be // used instead of Fn if specified FnName string // Args is a list of arguments to the function Args []interface{} }
FnCall is a struct used by marshaler
func NewFnCall ¶
func NewFnCall(fn interface{}, args ...interface{}) *FnCall
NewFnCall returns new FnCall instance
func (*FnCall) MarshalCode ¶
func (f *FnCall) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals object to code
func (*FnCall) SetExpressionArgs ¶
func (f *FnCall) SetExpressionArgs(expressions []Expression)
SetExpressionArgs sets arguments from expressions
type Function ¶
type Function interface { // NewInstance creates a new instance of the function // optionally creating a new lexical scope NewInstance(group Group) (Group, interface{}) }
Function creates new functions
func ConvertFunctionToAST ¶
ConvertFunctionToAST converts function fn into function with all arguments and return value converted to AST types
type GetEventFunc ¶
type GetEventFunc func(ctx ExecutionContext) Event
type Group ¶
type Group interface { // LexicalScope is a lexical scope // represented by this group LexicalScope // BroadcastEvents will broadcast events // to every process in a process group BroadcastEvents() chan<- Event // ExitEvent is set and returned when the group stop execution, // otherwise is nil, so callers should check for validity ExitEvent() ExitEvent // Context returns a process group context Context() context.Context // SetPlugin sets process group-local plugin // all setters and getters are thread safe SetPlugin(key interface{}, val interface{}) // GetPlugin returns a process group plugin // all setters and getters are thread safe GetPlugin(key interface{}) (val interface{}, exists bool) // Logger returns a logger associated with this group Logger() Logger // IsDebug returns a global debug override IsDebug() bool }
Group represents a group of processes
type IDAction ¶
type IDAction struct { }
IDAction returns force ID
func (*IDAction) Eval ¶
func (i *IDAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates id of the current execution context
func (*IDAction) MarshalCode ¶
func (i *IDAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals ID action to code
type IfAction ¶
type IfAction struct {
// contains filtered or unexported fields
}
IfAction runs actions in a sequence, if the action fails, next actions are not run
func (*IfAction) Eval ¶
func (s *IfAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval runs actions in sequence
func (*IfAction) EvalWithScope ¶
func (s *IfAction) EvalWithScope(ctx ExecutionContext) (interface{}, error)
EvalWithScope runs actions in sequence using the passed scope
func (*IfAction) MarshalCode ¶
func (p *IfAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
func (*IfAction) NewInstance ¶
NewInstance is used when If expression evaluates to lambda function
type Int ¶
type Int int
Int is a constant int var
func (Int) Eval ¶
func (i Int) Eval(ctx ExecutionContext) (interface{}, error)
Value returns int value
func (Int) MarshalCode ¶
func (i Int) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals the variable to code representation
type IntSlice ¶
type IntSlice []Expression
IntSlice represents a slice of integers
func (IntSlice) Eval ¶
func (s IntSlice) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates a list of var references to types
func (IntSlice) MarshalCode ¶
func (s IntSlice) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode
type IntVar ¶
type IntVar struct {
Expression
}
func (IntVar) Eval ¶
func (i IntVar) Eval(ctx ExecutionContext) (interface{}, error)
type IntVarFunc ¶
type IntVarFunc func(ctx ExecutionContext) (interface{}, error)
IntVarFunc wraps function and returns an interface Var
func (IntVarFunc) Eval ¶
func (f IntVarFunc) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates value and returns error
func (IntVarFunc) Type ¶
func (f IntVarFunc) Type() interface{}
type LambdaFunction ¶
type LambdaFunction struct { Scope Group Statements []Action Params []LambdaParam }
func ExpectLambdaFunction ¶
func ExpectLambdaFunction(expr Expression) (*LambdaFunction, error)
ExpectLambdaFunction expects expression to evaluate to lambda function
func (*LambdaFunction) Call ¶
func (f *LambdaFunction) Call(scope ExecutionContext) (interface{}, error)
Call attempts to call a function with no arguments
func (*LambdaFunction) Eval ¶
func (f *LambdaFunction) Eval(ctx ExecutionContext) (interface{}, error)
Eval runs the action in the context of the worker, could modify the context to add metadata, fields or error
func (*LambdaFunction) EvalWithScope ¶
func (f *LambdaFunction) EvalWithScope(scope ExecutionContext) (interface{}, error)
EvalWithScope runs actions in sequence using the passed scope
func (*LambdaFunction) ExpectEqualTypes ¶
func (f *LambdaFunction) ExpectEqualTypes(i interface{}) error
ExpectEqualTypes returns nil if the lambda function signatures (input argument types and evaluated value) are equal
func (*LambdaFunction) MarshalCode ¶
func (f *LambdaFunction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals code
func (*LambdaFunction) NewCall ¶
func (f *LambdaFunction) NewCall() (*LambdaFunctionCall, error)
NewCall creates a new call
func (*LambdaFunction) NewInstance ¶
func (f *LambdaFunction) NewInstance(group Group) (Group, interface{})
func (*LambdaFunction) Type ¶
func (f *LambdaFunction) Type() interface{}
type LambdaFunctionCall ¶
type LambdaFunctionCall struct { Expression Expression // Args defines arguments the lambda function has been called with Arguments []interface{} }
LambdaFunctionCall represents a call of a lambda function with arguments
func (*LambdaFunctionCall) CheckCall ¶
func (f *LambdaFunctionCall) CheckCall() error
CheckCall checks call type variables and parameters
func (*LambdaFunctionCall) Eval ¶
func (f *LambdaFunctionCall) Eval(ctx ExecutionContext) (interface{}, error)
Eval runs the action in the context of the worker, could modify the context to add metadata, fields or error
func (*LambdaFunctionCall) EvalStatements ¶
func (f *LambdaFunctionCall) EvalStatements(ctx ExecutionContext) ([]Action, error)
EvalStatements returns all statements from evaluated lambda function
func (*LambdaFunctionCall) EvalWithScope ¶
func (f *LambdaFunctionCall) EvalWithScope(scope ExecutionContext) (interface{}, error)
EvalWithScope runs actions in sequence using the passed scope and evalates to the value of the sequence (the last element of it)
func (*LambdaFunctionCall) LambdaType ¶
func (f *LambdaFunctionCall) LambdaType() (*LambdaFunction, error)
LambdaType returns a lambda function type
func (*LambdaFunctionCall) MarshalCode ¶
func (f *LambdaFunctionCall) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals code
func (*LambdaFunctionCall) Type ¶
func (f *LambdaFunctionCall) Type() interface{}
LambdaFunctionCall evaluates to it's last statement
type LambdaParam ¶
type LambdaParam struct { Name string Prototype interface{} }
type LexScope ¶
LexScope wraps a group to create a new lexical scope
func WithLexicalScope ¶
WithLexicalScope wraps a group to create a new lexical scope
func WithParent ¶
WithParent wraps a group to create a new lexical scope
func (*LexScope) AddDefinition ¶
AddDefinition defines variable to track its type the variable is set on the execution context
func (*LexScope) GetDefinition ¶
GetDefinition gets a variable defined with DefineVarType not the actual variable value is returned, but a prototype value specifying the type
type LexicalScope ¶
type LexicalScope interface { // AddDefinition adds variable definition in the current lexical scop AddDefinition(name string, v interface{}) error // GetDefinition gets a variable defined with DefineVarType // not the actual variable value is returned, but a prototype // value specifying the type GetDefinition(name string) (interface{}, error) // Variables returns a list of variable names // defined in this scope (and the parent scopes) Variables() []string // GetParent returns a parent scope definition, // NotFound error is returned if scope has no parent GetParent() (interface{}, error) // SetParent sets parent type of the scope SetParent(p interface{}) }
LexicalScope is a lexical scope with variables
type LocalExitEvent ¶
type LocalExitEvent struct { Code int // contains filtered or unexported fields }
func (LocalExitEvent) AddMetadata ¶
func (e LocalExitEvent) AddMetadata(ctx ExecutionContext)
func (LocalExitEvent) Created ¶
func (e LocalExitEvent) Created() time.Time
func (LocalExitEvent) ExitCode ¶
func (e LocalExitEvent) ExitCode() int
func (LocalExitEvent) String ¶
func (e LocalExitEvent) String() string
String returns a string description of the event
type Logger ¶
type Logger interface { // WithError returns a logger bound to an error WithError(error) Logger Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) // URL returns a URL for viewing the logs // associated with this execution context URL(ExecutionContext) string // AddFields adds fields to the logger AddFields(fields map[string]interface{}) Logger }
Logger is an interface to the logger
type Marshaler ¶
type Marshaler struct {
// contains filtered or unexported fields
}
Marshaler marshals expression to string
func Marshal ¶
func Marshal(node interface{}) *Marshaler
Marshal marshals expression to its code representation without evaluating it (unless some parts of the expression) are unquoted using Unquote
func (*Marshaler) Eval ¶
func (n *Marshaler) Eval(ctx ExecutionContext) (interface{}, error)
Eval returns code representation of the expression without evaluating it
func (*Marshaler) MarshalCode ¶
func (n *Marshaler) MarshalCode(ctx ExecutionContext) ([]byte, error)
type NewDefine ¶
type NewDefine struct { }
NewDefine specifies a new define action
func (*NewDefine) NewInstance ¶
NewInstance returns a new instance of define
type NewIf ¶
type NewIf struct { }
NewIf creates a new conditional action with a new lexical scope
func (*NewIf) NewInstance ¶
NewInstance returns a new instance of a function with a new lexical scope
type NewParallel ¶
type NewParallel struct { }
NewParallel creates a new series of actions executed in parallel
func (*NewParallel) NewInstance ¶
func (n *NewParallel) NewInstance(group Group) (Group, interface{})
NewInstance returns a new instance
type NewSequence ¶
type NewSequence struct { }
NewSequence creates a new sequence with a new lexical scope
func (*NewSequence) NewInstance ¶
func (n *NewSequence) NewInstance(group Group) (Group, interface{})
NewInstance returns a new instance of a function with a new lexical scope
type NewVarRef ¶
type NewVarRef struct { }
NewVarRef returns new variable references
func (*NewVarRef) NewInstance ¶
NewInstance returns a new instance
type NopAction ¶
type NopAction struct { FnName string Args []Expression EvalType interface{} }
NopAction does nothing, is used to wrap arbitrary arguments
func (*NopAction) Eval ¶
func (s *NopAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval runs shell script and returns output as a string
func (*NopAction) MarshalCode ¶
func (s *NopAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
type NopScope ¶
type NopScope struct {
Func interface{}
}
NopScope wraps func to create new instances not bound to new lexical scope and not referencing any scopes
func (*NopScope) NewInstance ¶
NewInstance retunrs the same func not bound to any scopes
type OneshotChannel ¶
type OneshotChannel struct {
// contains filtered or unexported fields
}
func (*OneshotChannel) Done ¶
func (o *OneshotChannel) Done() <-chan struct{}
func (*OneshotChannel) Events ¶
func (o *OneshotChannel) Events() <-chan Event
func (*OneshotChannel) MarshalCode ¶
func (o *OneshotChannel) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals channel to code
func (*OneshotChannel) String ¶
func (o *OneshotChannel) String() string
type OneshotEvent ¶
func (OneshotEvent) AddMetadata ¶
func (e OneshotEvent) AddMetadata(ctx ExecutionContext)
func (*OneshotEvent) Created ¶
func (o *OneshotEvent) Created() time.Time
func (*OneshotEvent) String ¶
func (o *OneshotEvent) String() string
type ParallelAction ¶
type ParallelAction struct {
// contains filtered or unexported fields
}
ParallelAction runs actions in parallel waits for all to complete, if any of them fail, returns error
func (*ParallelAction) Eval ¶
func (p *ParallelAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval runs actions in parallel and returns a slice of results
func (*ParallelAction) MarshalCode ¶
func (p *ParallelAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
func (*ParallelAction) Type ¶
func (p *ParallelAction) Type() interface{}
Type returns a slice of actions' results
type PipeNetConn ¶
type PipeNetConn struct {
// contains filtered or unexported fields
}
PipeNetConn implemetns net.Conn from io.Reader,io.Writer and io.Closer
func NewPipeNetConn ¶
func NewPipeNetConn(reader io.Reader, writer io.Writer, closer io.Closer, fakelocalAddr net.Addr, fakeRemoteAddr net.Addr) *PipeNetConn
NewPipeNetConn returns a net.Conn like object using Pipe as an underlying implementation over reader, writer and closer
func (*PipeNetConn) Close ¶
func (nc *PipeNetConn) Close() error
func (*PipeNetConn) LocalAddr ¶
func (nc *PipeNetConn) LocalAddr() net.Addr
func (*PipeNetConn) RemoteAddr ¶
func (nc *PipeNetConn) RemoteAddr() net.Addr
func (*PipeNetConn) SetDeadline ¶
func (nc *PipeNetConn) SetDeadline(t time.Time) error
func (*PipeNetConn) SetReadDeadline ¶
func (nc *PipeNetConn) SetReadDeadline(t time.Time) error
func (*PipeNetConn) SetWriteDeadline ¶
func (nc *PipeNetConn) SetWriteDeadline(t time.Time) error
type Process ¶
type Process interface { Expression // Name returns a process name Name() string // Channel returns a process channel Channel() Channel // Action returns actions assigned to the process Action() Action // Events returns a channel that receives events Events() chan<- Event // Start is a non blocking call Start(ctx ExecutionContext) error // Runner returns a process group // this process belongs to Group() Group // Done signals that process has completed // handling channel events and exited Done() <-chan struct{} // String returns user friendly process name String() string }
Process is a process that is triggered by the event
type RuntimeScope ¶
type RuntimeScope struct { *sync.RWMutex ExecutionContext // contains filtered or unexported fields }
RuntimeScope wraps an execution context to create a new one with new variable values
func WithRuntimeScope ¶
func WithRuntimeScope(ctx ExecutionContext) *RuntimeScope
WithRuntimeScope wraps a group to create a new runtime scope
func (*RuntimeScope) SetValue ¶
func (l *RuntimeScope) SetValue(key interface{}, value interface{}) error
SetValue sets a key value pair
func (*RuntimeScope) Value ¶
func (l *RuntimeScope) Value(key interface{}) interface{}
Value returns a value
type ScopeAction ¶
type ScopeAction interface { Action // EvalWithScope evaluates action in sequence using the passed scope EvalWithScope(scope ExecutionContext) (interface{}, error) }
ScopeAction can run in the context of the scope instead of creating a new one
func If ¶
func If(condition Expression, action Action, elseActions ...Action) (ScopeAction, error)
If performs conditional execution of an action
func Sequence ¶
func Sequence(actions ...Action) (ScopeAction, error)
Sequence groups sequence of commands together, if one fails, the chain stop execution
type Script ¶
type Script struct { // ExportEnv exports all variables from host environment ExportEnv Expression // EchoArgs logs arguments EchoArgs Expression // Command is an inline script, shortcut for // /bin/sh -c args... Command Expression // Args is a list of arguments, if supplied // used instead of the command Args []Expression // WorkingDir is a working directory WorkingDir Expression // Env is a list of key value environment variables Env []Expression }
Script is a shell script
func (*Script) CheckAndSetDefaults ¶
func (s *Script) CheckAndSetDefaults(ctx ExecutionContext) error
CheckAndSetDefaults checks and sets default values
type SendAction ¶
type SendAction struct { GetEvent GetEventFunc Process Process }
func (*SendAction) Eval ¶
func (e *SendAction) Eval(ctx ExecutionContext) (interface{}, error)
func (*SendAction) MarshalCode ¶
func (e *SendAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action to code representation
func (*SendAction) Type ¶
func (e *SendAction) Type() interface{}
type SequenceAction ¶
type SequenceAction struct {
// contains filtered or unexported fields
}
SequenceAction runs actions in a sequence, if the action fails, next actions are not run
func (*SequenceAction) Eval ¶
func (s *SequenceAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates actions in sequence
func (*SequenceAction) EvalWithScope ¶
func (s *SequenceAction) EvalWithScope(ctx ExecutionContext) (interface{}, error)
RunWithScope runs actions in sequence using the passed scope
func (*SequenceAction) MarshalCode ¶
func (p *SequenceAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
func (*SequenceAction) Type ¶
func (p *SequenceAction) Type() interface{}
type ShellAction ¶
type ShellAction struct {
// contains filtered or unexported fields
}
ShellAction runs shell script
func (*ShellAction) Eval ¶
func (s *ShellAction) Eval(ctx ExecutionContext) (interface{}, error)
Eval runs shell script and returns output as a string
func (*ShellAction) MarshalCode ¶
func (s *ShellAction) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals action into code representation
func (*ShellAction) String ¶
func (s *ShellAction) String() string
func (*ShellAction) Type ¶
func (s *ShellAction) Type() interface{}
type Snippet ¶
Snippet is a snippet captured from the source file based on the position
func CaptureSnippet ¶
CaptureSnippet captures snippet near position near newline
type Spec ¶
type Spec struct { Name String Watch Channel Run Action EventsC chan Event `code:"-"` // Group if set, will assign the process to a specific group, // otherwise, will be set to the default runner Group Group `code:"-"` }
Spec is a process specification
func (*Spec) CheckAndSetDefaults ¶
type String ¶
type String string
String is a constant string variable
func (String) Eval ¶
func (s String) Eval(ctx ExecutionContext) (interface{}, error)
Value evaluates function and returns string
func (String) MarshalCode ¶
func (s String) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals ID action to code
type StringSlice ¶
type StringSlice []Expression
StringSlice represents a slice of strings
func (StringSlice) Eval ¶
func (s StringSlice) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates a list of var references to types
func (StringSlice) MarshalCode ¶
func (s StringSlice) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode
type StringVar ¶
type StringVar struct {
Expression
}
func (StringVar) Eval ¶
func (s StringVar) Eval(ctx ExecutionContext) (interface{}, error)
type StringVarFunc ¶
type StringVarFunc func(ctx ExecutionContext) (string, error)
StringVarFunc wraps function and returns an interface StringVar
func (StringVarFunc) Eval ¶
func (f StringVarFunc) Eval(ctx ExecutionContext) (string, error)
Value returns a string value
func (StringVarFunc) Type ¶
func (f StringVarFunc) Type() interface{}
Type returns the type of the variable
type StringsVar ¶
type StringsVar struct {
Expression
}
func (StringsVar) Convert ¶
func (b StringsVar) Convert(i interface{}) (interface{}, error)
func (StringsVar) Eval ¶
func (b StringsVar) Eval(ctx ExecutionContext) (interface{}, error)
func (StringsVar) Type ¶
func (b StringsVar) Type() interface{}
type SyncBuffer ¶
type SyncBuffer struct {
// contains filtered or unexported fields
}
SyncBuffer is in memory bytes buffer that is safe for concurrent writes
func NewSyncBuffer ¶
func NewSyncBuffer() *SyncBuffer
NewSyncBuffer returns new in memory buffer that is safe to read/write by multiple goroutines
func (*SyncBuffer) Bytes ¶
func (b *SyncBuffer) Bytes() []byte
Bytes returns contents of the buffer after this call, all writes will fail
func (*SyncBuffer) Close ¶
func (b *SyncBuffer) Close() error
Close closes reads and writes on the buffer
func (*SyncBuffer) String ¶
func (b *SyncBuffer) String() string
String returns contents of the buffer after this call, all writes will fail
type Test ¶
type Test struct { // I is an integer variable I Expression // S is a string variable S Expression // B is a bool variable B Expression }
Test is a struct used for tests
type TickEvent ¶
func (TickEvent) AddMetadata ¶
func (e TickEvent) AddMetadata(ctx ExecutionContext)
type TickerChannel ¶
type TickerChannel struct {
// contains filtered or unexported fields
}
func (*TickerChannel) Done ¶
func (o *TickerChannel) Done() <-chan struct{}
func (*TickerChannel) Events ¶
func (o *TickerChannel) Events() <-chan Event
func (*TickerChannel) MarshalCode ¶
func (o *TickerChannel) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals channel to code
func (*TickerChannel) String ¶
func (o *TickerChannel) String() string
type TypeChecker ¶
type TypeChecker interface { // ExpectEqualTypes returns nil if the types are identical // error otherwise ExpectEqualTypes(i interface{}) error }
TypeChecker is used to test two types for equivalence
type TypeConverter ¶
type TypeConverter struct { // Converter is an internal converter // type, if present will be used Converter Converter }
TypeConverter is a helper that converts types
func NewTypeConverter ¶
func NewTypeConverter(t reflect.Type) *TypeConverter
NewTypeConverter returns a new type conveter
type Unquoter ¶
type Unquoter struct {
// contains filtered or unexported fields
}
Unquoter unquotes the expression
func Unquote ¶
func Unquote(node Expression) *Unquoter
Unquote evaluates the argument first, and then returns code representation of the returned result
func (*Unquoter) Eval ¶
func (u *Unquoter) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates the argument first, and then returns code representation of the returned result
func (*Unquoter) MarshalCode ¶
func (u *Unquoter) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode marshals code
type VarRef ¶
type VarRef struct {
// contains filtered or unexported fields
}
VarRef is a variable reference, evaluates to the expression
func (*VarRef) Eval ¶
func (v *VarRef) Eval(ctx ExecutionContext) (interface{}, error)
Eval evaluates variable reference and checks types
func (*VarRef) MarshalCode ¶
func (v *VarRef) MarshalCode(ctx ExecutionContext) ([]byte, error)
MarshalCode evaluates bool variable reference to code representation
type WrapContext ¶
WrapContext wraps context
func (*WrapContext) Event ¶
func (c *WrapContext) Event() Event
Event is an event that generated the action
func (*WrapContext) Process ¶
func (c *WrapContext) Process() Process
Process returns a process associated with the context
func (*WrapContext) SetValue ¶
func (w *WrapContext) SetValue(key interface{}, value interface{}) error
SetValue sets a key value pair