Documentation
¶
Overview ¶
Package compiler provides a compiler for the goja runtime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Per Execution Javascript timeout in seconds JsProtocolTimeout = 10 JsVmConcurrency = 500 )
Functions ¶
func InternalGetGeneratorRuntime ¶ added in v3.1.8
Internal purposes i.e generating bindings
Types ¶
type Compiler ¶
type Compiler struct{}
Compiler provides a runtime to execute goja runtime based javascript scripts efficiently while also providing them access to custom modules defined in libs/.
func (*Compiler) Execute ¶
func (c *Compiler) Execute(code string, args *ExecuteArgs) (ExecuteResult, error)
Execute executes a script with the default options.
func (*Compiler) ExecuteWithOptions ¶
func (c *Compiler) ExecuteWithOptions(program *goja.Program, args *ExecuteArgs, opts *ExecuteOptions) (ExecuteResult, error)
ExecuteWithOptions executes a script with the provided options.
type ExecuteArgs ¶
type ExecuteArgs struct {
Args map[string]interface{} //these are protocol variables
TemplateCtx map[string]interface{} // templateCtx contains template scoped variables
}
ExecuteArgs is the arguments to pass to the script.
func NewExecuteArgs ¶
func NewExecuteArgs() *ExecuteArgs
NewExecuteArgs returns a new execute arguments.
type ExecuteOptions ¶
type ExecuteOptions struct {
// Callback can be used to register new runtime helper functions
// ex: export etc
Callback func(runtime *goja.Runtime) error
// Cleanup is extra cleanup function to be called after execution
Cleanup func(runtime *goja.Runtime)
/// Timeout for this script execution
Timeout int
}
ExecuteOptions provides options for executing a script.
type ExecuteResult ¶
type ExecuteResult map[string]interface{}
ExecuteResult is the result of executing a script.
func NewExecuteResult ¶
func NewExecuteResult() ExecuteResult
func (ExecuteResult) GetSuccess ¶
func (e ExecuteResult) GetSuccess() bool
GetSuccess returns whether the script was successful or not.
Click to show internal directories.
Click to hide internal directories.