plugin

package
v0.0.0-...-9b5f04d Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package plugin implements Nova's Lua-based plugin system. Plugins are .lua files discovered from ~/.nova/plugins/ that can hook into DNS resolution, VM lifecycle events, and network conditioning.

Index

Constants

View Source
const (
	HookDNSResolve = "dns_resolve" // (hostname) -> ip or nil
	HookOnVMStart  = "on_vm_start" // (vm_name)
	HookOnVMStop   = "on_vm_stop"  // (vm_name)
	HookOnSnapshot = "on_snapshot" // (snapshot_name)
	HookOnLink     = "on_link"     // (node_a, node_b, action)
)

Hook points that plugins can register for.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager discovers, loads, and dispatches to Lua plugins.

func NewManager

func NewManager(pluginDir string) (*Manager, error)

NewManager creates a plugin Manager that loads plugins from the given directory.

func (*Manager) CallHook

func (m *Manager) CallHook(hook string, args ...string) string

CallHook dispatches a hook event to all loaded plugins that registered for it. Returns the first non-nil string result (useful for dns_resolve), or "".

func (*Manager) CallHookAll

func (m *Manager) CallHookAll(hook string, args ...string) []string

CallHookAll dispatches a hook to all plugins and collects all non-empty results.

func (*Manager) Close

func (m *Manager) Close()

Close shuts down all plugin Lua states.

func (*Manager) LoadAll

func (m *Manager) LoadAll() error

LoadAll discovers and loads all .lua files in the plugin directory.

func (*Manager) PluginCount

func (m *Manager) PluginCount() int

PluginCount returns the number of loaded plugins.

func (*Manager) RegisterHostFunc

func (m *Manager) RegisterHostFunc(name string, fn lua.LGFunction)

RegisterHostFunc adds a Go function that plugins can call via nova.<name>().

type Plugin

type Plugin struct {
	Name string
	Path string
	L    *lua.LState
}

Plugin represents a loaded Lua plugin.

Jump to

Keyboard shortcuts

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