Documentation
¶
Overview ¶
Package lua provides Lua-backed Hive plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandsModule ¶
type CommandsModule struct {
// contains filtered or unexported fields
}
CommandsModule exposes `hive.commands(map)` and accumulates registered commands. Read them out via Commands() after the entrypoint runs.
A CommandsModule is single-use: registration writes into its commands map, so create a fresh instance per Runtime.
func (*CommandsModule) Commands ¶
func (m *CommandsModule) Commands() map[string]config.UserCommand
Commands returns the commands registered by the Lua plugin. Returns an empty map until at least one Register call has occurred.
type HostModule ¶
HostModule registers part of the `hive` host API on the Lua state. Each module owns its own state and the field(s) it attaches to the hive table; adding a new API surface is "implement Register and pass an instance to NewRuntime."
type LogModule ¶
type LogModule struct {
PluginName string
}
LogModule exposes `hive.log.{debug,info,warn,error}` functions that emit to the standard Hive log with a "plugin" field tagged with PluginName.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin adapts a Lua entry file to Hive's plugin interface.
func (*Plugin) StatusProvider ¶
func (p *Plugin) StatusProvider() plugins.StatusProvider
type PluginInfoModule ¶
PluginInfoModule exposes static metadata about the running plugin via `hive.plugin.{name,entry,module_root}`.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns a sandboxed Lua state for a Hive plugin. The state is private: callers interact through LoadEntrypoint / CallEntrypoint / Close.
func NewRuntime ¶
func NewRuntime(moduleRoot string, modules ...HostModule) (*Runtime, error)
NewRuntime constructs a sandboxed Lua runtime, configures `require()` to resolve relative to moduleRoot, and registers each HostModule onto the global `hive` table in order.
func (*Runtime) CallEntrypoint ¶
CallEntrypoint invokes the plugin entry function in protected mode, passing the global `hive` table as its single argument.