Help us shape the future of Go! Take the 2026 Go Developer Survey

lua

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type InstanceInfo struct {
	Mode       VMMode
	Persistent bool
	Paused     bool
	Killed     bool
	Locked     bool
}

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

func NewManager(logger *log.Loggee) *Manager

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

func (m *Manager) Do(id uuid.UUID, action VMAction) error

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

func (m *Manager) RegisterGlobal(name string, value lua.LValue)

RegisterGlobal exposes a Go value to all future Lua states managed by this manager.

func (*Manager) SetDefaultSender

func (m *Manager) SetDefaultSender(sender string)

SetDefaultSender overrides the sender name used when logging from scripts.

func (*Manager) StartVM added in v0.12.4

func (m *Manager) StartVM(mode VMMode, persistent bool, code string) (*uuid.UUID, error)

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 VMAction = iota
	ReRunSafe
	Pause
	Resume
	Terminate
	Kill
)

func (VMAction) String added in v0.12.4

func (a VMAction) String() string

String converts the VM action to a readable representation.

type VMMode added in v0.12.2

type VMMode uint8
const (
	Sandboxed VMMode = iota
	Elevated
	Unsafe
)

func (VMMode) String added in v0.12.4

func (m VMMode) String() string

String converts the VM mode to a readable representation.

Source Files

  • instance.go
  • manager.go

Jump to

Keyboard shortcuts

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