Documentation
¶
Overview ¶
Package plugin provides a plugable infrastructure for native envel bindings Plugins are loaded when envel is started and can preload code to be exposed to the event loop / lua LState
Index ¶
Constants ¶
const SymbolName = "Plugin"
SymbolName defines the name of the symbol that should be exposed by all plugins and should implement the Plugin interface
Variables ¶
var DefaultLoader = &defaultLoader{}
DefaultLoader is the default plugin loader used by LoadDirectory() and LoadFile()
Functions ¶
Types ¶
type Binding ¶
type Binding interface { // Preload is called when the binding should preload itself into the provided // lua state. Note that this function may be called mutliple times with different // lua states. The plugin must NOT share objects between different states Preload(*lua.LState) error }
Binding describes a plugin type that provides additional native bindings for envel
type Instance ¶
type Instance interface { Plugin // Name returns the filename of the plugin Name() string // Path returns the path to the plugin file Path() string }
Instance represents a loaded plugin
func LoadDirectory ¶
LoadDirectory loads all plugins from the given directory. It used DefaultLoader as the plugin Loader
type Loader ¶
type Loader interface { // LoadDirectory loads all plugins from the given directory // If the specified path is a file, it should try to directly load the file LoadDirectory(path string) ([]Instance, error) // LoadFile loads an envel plugin from the given file LoadFile(path string) (Instance, error) }
Loader provides methods for loading plugins
type Option ¶
type Option func(p *pluginImpl)
Option defines the type of function that serves as a plugin option
func WithBinding ¶
WithBinding adds a new binding the the plugin This is a singular alias for WithBindings
func WithBindings ¶
WithBindings adds one or more bindings to the plugin
type Plugin ¶
type Plugin interface { // Init is called to initialize the plugin. It is called exactly once when // the plugin is loaded Init() error // Bindings should return a list of native lua bindings or nil if none are supported // by the plugin Bindings() []Binding }
Plugin describes a plugin for envel