plugin

package
v0.0.0-...-d78e010 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name        string
	Description string
	Usage       string
	Handler     func(args []string) (interface{}, error)
}

Command represents a plugin command

type Plugin

type Plugin interface {
	// Metadata
	Name() string
	Version() string
	Description() string
	Author() string

	// Lifecycle
	Init(config map[string]interface{}) error
	Start() error
	Stop() error
	Cleanup() error

	// Hooks
	OnConnect(host string, port int) error
	OnDisconnect(host string, port int) error
	OnDataReceived(data []byte) ([]byte, error)
	OnDataSent(data []byte) ([]byte, error)
	OnError(err error)

	// Commands
	GetCommands() []Command
	ExecuteCommand(name string, args []string) (interface{}, error)
}

Plugin interface that all plugins must implement

type PluginManager

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

PluginManager manages all loaded plugins

func NewPluginManager

func NewPluginManager(pluginPath string) *PluginManager

NewPluginManager creates a new plugin manager

func (*PluginManager) DisablePlugin

func (pm *PluginManager) DisablePlugin(name string) error

DisablePlugin disables a plugin

func (*PluginManager) EnablePlugin

func (pm *PluginManager) EnablePlugin(name string) error

EnablePlugin enables a plugin

func (*PluginManager) ExecuteHook

func (pm *PluginManager) ExecuteHook(hookName string, args ...interface{}) error

ExecuteHook executes a hook for all enabled plugins

func (*PluginManager) ExecutePluginCommand

func (pm *PluginManager) ExecutePluginCommand(pluginName, commandName string, args []string) (interface{}, error)

ExecutePluginCommand executes a command on a specific plugin

func (*PluginManager) GetAllCommands

func (pm *PluginManager) GetAllCommands() map[string][]Command

GetAllCommands returns all commands from all enabled plugins

func (*PluginManager) GetPlugin

func (pm *PluginManager) GetPlugin(name string) (Plugin, bool)

GetPlugin returns a plugin by name

func (*PluginManager) ListPlugins

func (pm *PluginManager) ListPlugins() []Plugin

ListPlugins returns a list of all loaded plugins

func (*PluginManager) LoadAllPlugins

func (pm *PluginManager) LoadAllPlugins() error

LoadAllPlugins loads all plugins from the plugin directory

func (*PluginManager) LoadPlugin

func (pm *PluginManager) LoadPlugin(filename string) error

LoadPlugin loads a plugin from a .so file

func (*PluginManager) PrintPluginInfo

func (pm *PluginManager) PrintPluginInfo()

PrintPluginInfo prints information about all loaded plugins

func (*PluginManager) ProcessData

func (pm *PluginManager) ProcessData(data []byte, direction string) ([]byte, error)

ProcessData processes data through all enabled plugins

func (*PluginManager) Shutdown

func (pm *PluginManager) Shutdown() error

Shutdown shuts down all plugins

func (*PluginManager) UnloadPlugin

func (pm *PluginManager) UnloadPlugin(name string) error

UnloadPlugin unloads a plugin

Jump to

Keyboard shortcuts

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