lua

package
v0.0.0-...-65871c1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sandbox

type Sandbox struct {
	// contains filtered or unexported fields
}

Sandbox represents a lua VM wich exposes a series of builtin functions to perform I/O operations and transformations over logging.Log structures.

func NewSandbox

func NewSandbox(scriptPath string) (l *Sandbox, err error)

NewSandbox allocates storage and initializes a new Sandbox

func (*Sandbox) CallOnLog

func (l *Sandbox) CallOnLog(lg *logging.Log) (err error)

CallOnLog will call this lua sandbox's on_log function with the given log pointer or it will return an error if on_log is not defined.

func (*Sandbox) CallOnSignal

func (l *Sandbox) CallOnSignal(signal os.Signal)

CallOnSignal allows the hosted lua script to handle a signal received by this Sandbox. There's no guarantees about the state of the program after the signal is handed to the script. In the case of SIGUSR1 and SIGUSR2, the signals are first handled by the script.

func (*Sandbox) Close

func (l *Sandbox) Close()

Close will shut down all the resources held by this Sandbox and flush all the pending I/O operations. Init must be called again if this instance is to be used.

func (*Sandbox) Flush

func (l *Sandbox) Flush()

Flush will try to flush all pending I/O operations.

func (*Sandbox) Init

func (l *Sandbox) Init(scriptPath string) (err error)

Init initializes l by instantiating a fresh lua state and loading the given script along with the standard lua libraries in it. If cfg is nil, a default configuration is used.

func (*Sandbox) ProtectedCallOnLog

func (l *Sandbox) ProtectedCallOnLog(lg *logging.Log) (err error)

ProtectedCallOnLog behaves like CallOnLog except that if there's a lua runtime error, it will look for 'on_error' hook and call it.

func (*Sandbox) ProtectedMode

func (l *Sandbox) ProtectedMode() bool

ProtectedMode returns whether sandbox is configured to run in protected mode. In this mode, when a lua runtime error is thrown by function logd.on_log, function logd.on_error(logptr, error) is called. This mode is toggled by calling logd.config_set("protected", true/false) or by the initial sandbox configuration

func (*Sandbox) SignalHandlerDefined

func (l *Sandbox) SignalHandlerDefined() bool

SignalHandlerDefined returns true if `logd.on_signal` hook is defined by hosted script

Jump to

Keyboard shortcuts

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