Documentation
¶
Index ¶
- type Sandbox
- func (l *Sandbox) CallOnLog(lg *logging.Log) (err error)
- func (l *Sandbox) CallOnSignal(signal os.Signal)
- func (l *Sandbox) Close()
- func (l *Sandbox) Flush()
- func (l *Sandbox) Init(scriptPath string) (err error)
- func (l *Sandbox) ProtectedCallOnLog(lg *logging.Log) (err error)
- func (l *Sandbox) ProtectedMode() bool
- func (l *Sandbox) SignalHandlerDefined() bool
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 ¶
NewSandbox allocates storage and initializes a new Sandbox
func (*Sandbox) CallOnLog ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
SignalHandlerDefined returns true if `logd.on_signal` hook is defined by hosted script