Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultTimeoutValue default timeout value for virtual machines DefaultTimeoutValue = 30 * time.Second // DefaultMaxVirtualMachines max number of virtual machines that can be loaded at one time DefaultMaxVirtualMachines uint8 = 10 // TypeLoad text to display in script_event table when a VM is loaded TypeLoad = "load" // TypeCreate text to display in script_event table when a VM is created TypeCreate = "create" // TypeExecute text to display in script_event table when a script is executed TypeExecute = "execute" // TypeStop text to display in script_event table when a running script is stopped TypeStop = "stop" // TypeRead text to display in script_event table when a script contents is read TypeRead = "read" // StatusSuccess text to display in script_event table on successful execution StatusSuccess = "success" // StatusFailure text to display in script_event table when script execution fails StatusFailure = "failure" )
View Source
const (
// ErrNoVMFound error returned when no virtual machine is found
ErrNoVMFound = "VM %v not found"
)
Variables ¶
View Source
var ( // GCTScriptConfig initialised global copy of Config{} GCTScriptConfig = &Config{} // ScriptPath path to load/save scripts ScriptPath string )
View Source
var ( // ErrScriptingDisabled error message displayed when gctscript is disabled ErrScriptingDisabled = errors.New("scripting is disabled") // ErrNoVMLoaded error message displayed if a virtual machine has not been initialised ErrNoVMLoaded = errors.New("no virtual machine loaded") )
View Source
var ( // AllVMSync stores all current Virtual Machine instances AllVMSync = &sync.Map{} // VMSCount running total count of Virtual Machines VMSCount vmscount )
Functions ¶
func SetDefaultScriptOutput ¶
func SetDefaultScriptOutput()
SetDefaultScriptOutput sets default output file for scripts
Types ¶
type Config ¶
type Config struct { Enabled bool `json:"enabled"` ScriptTimeout time.Duration `json:"timeout"` MaxVirtualMachines uint8 `json:"max_virtual_machines"` AllowImports bool `json:"allow_imports"` AutoLoad []string `json:"auto_load"` Verbose bool `json:"verbose"` }
Config user configurable options for gctscript
type VM ¶
type VM struct { ID uuid.UUID Hash string File string Path string Script *tengo.Script Compiled *tengo.Compiled T time.Duration NextRun time.Time S chan struct{} // contains filtered or unexported fields }
VM contains a pointer to "script" (precompiled source) and "compiled" (compiled byte code) instances
func (*VM) CompileAndRun ¶
func (vm *VM) CompileAndRun()
CompileAndRun Compile and Run script with support for task running
Click to show internal directories.
Click to hide internal directories.