Documentation
¶
Index ¶
- Variables
- type InstanceInfo
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Do(id uuid.UUID, action VMAction) error
- func (m *Manager) InstanceInfo(id uuid.UUID) (InstanceInfo, error)
- func (m *Manager) RegisterFunction(name string, fn lua.LGFunction)
- func (m *Manager) RegisterGlobal(name string, value lua.LValue)
- func (m *Manager) SetDefaultSender(sender string)
- func (m *Manager) StartVM(mode VMMode, persistent bool, code string) (*uuid.UUID, error)
- type VMAction
- type VMMode
Constants ¶
This section is empty.
Variables ¶
var ( ErrInstanceNotFound = errors.New("scripting: instance not found") ErrInstanceBusy = errors.New("scripting: instance is locked") ErrInstancePaused = errors.New("scripting: instance is paused") ErrInstanceKilled = errors.New("scripting: instance is killed") )
Manager level errors to aid callers when coordinating VM access.
Functions ¶
This section is empty.
Types ¶
type InstanceInfo ¶ added in v0.12.4
InstanceInfo reports metadata about a tracked VM instance.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates multiple sandboxed Lua states.
func NewManager ¶
NewManager creates a manager with an optional logger. When logger is nil, scripting logs are dropped.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops all persistent instances managed by this manager.
func (*Manager) Do ¶ added in v0.12.4
Do performs an action against a persistent VM identified by id.
func (*Manager) InstanceInfo ¶ added in v0.12.4
func (m *Manager) InstanceInfo(id uuid.UUID) (InstanceInfo, error)
InstanceInfo returns metadata for the VM identified by id.
func (*Manager) RegisterFunction ¶
func (m *Manager) RegisterFunction(name string, fn lua.LGFunction)
RegisterFunction exposes a Go function to all future Lua states managed by this manager.
func (*Manager) RegisterGlobal ¶ added in v0.12.4
RegisterGlobal exposes a Go value to all future Lua states managed by this manager.
func (*Manager) SetDefaultSender ¶
SetDefaultSender overrides the sender name used when logging from scripts.
func (*Manager) StartVM ¶ added in v0.12.4
StartVM compiles and executes the provided script according to the requested mode. Persistent VMs remain tracked and can be controlled via Do; volatile ones run once and are discarded immediately after execution. Every VM receives a UUIDv7 identifier.
type VMAction ¶ added in v0.12.4
type VMAction uint8
VMAction enumerates supported manager operations for persistent VMs.
const ( // ReRun rebuilds the Lua stack and runs the script, blocking until the VM lock is held. ReRun VMAction = iota // ReRunSafe only reruns when TryLock succeeds and otherwise returns ErrInstanceBusy. ReRunSafe // Pause flips the paused flag so future runs reject immediately. Pause // Resume clears the paused flag to allow execution again. Resume // Terminate waits for the current run to finish, then removes the VM cleanly. Terminate // Kill forcibly removes the VM immediately without waiting for the run to finish. Kill )
Source Files
¶
- instance.go
- manager.go