plugin

package
v0.0.0-...-4b2a75f Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const FactorySymbol = "NewPluginFactory"

FactorySymbol is the exported symbol name for dynamic loading

View Source
const Version = "1.0.0"

Version is the semantic versioning for the plugin API

Variables

This section is empty.

Functions

This section is empty.

Types

type DecoderPlugin

type DecoderPlugin interface {
	// Name returns the plugin identifier
	Name() string

	// Version returns the plugin version following semver
	Version() string

	// CanDecode returns true if this plugin can handle the given event
	CanDecode(eventType string) bool

	// Decode processes the event and returns decoded data
	Decode(data []byte) (json.RawMessage, error)

	// Metadata returns plugin capabilities and requirements
	Metadata() Metadata
}

DecoderPlugin defines the interface for custom decoder plugins

type Factory

type Factory interface {
	Create() (DecoderPlugin, error)
}

Factory creates a plugin instance

type Loader

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

Loader manages plugin discovery and initialization

func NewLoader

func NewLoader() *Loader

NewLoader creates a new plugin loader

func (*Loader) FindForEvent

func (l *Loader) FindForEvent(eventType string) (DecoderPlugin, bool)

FindForEvent returns the first plugin that can decode the event type

func (*Loader) Get

func (l *Loader) Get(name string) (DecoderPlugin, bool)

Get retrieves a loaded plugin by name

func (*Loader) List

func (l *Loader) List() []string

List returns all loaded plugin names

func (*Loader) Load

func (l *Loader) Load(path string) error

Load opens and initializes a plugin from a shared library file

type Manager

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

Manager coordinates plugin operations with the main decoder system

func NewManager

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

NewManager creates a plugin manager with an optional base directory

func (*Manager) DecodeEvent

func (m *Manager) DecodeEvent(eventType string, data []byte) (json.RawMessage, error)

DecodeEvent decodes using the most appropriate plugin

func (*Manager) DecodeEventWithPlugin

func (m *Manager) DecodeEventWithPlugin(pluginName string, eventType string, data []byte) (json.RawMessage, error)

DecodeEventWithPlugin uses a specific plugin

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(name string) (DecoderPlugin, bool)

GetPlugin retrieves a specific plugin

func (*Manager) GetPlugins

func (m *Manager) GetPlugins() []Metadata

GetPlugins returns available plugins

func (*Manager) Initialize

func (m *Manager) Initialize() error

Initialize loads plugins from the plugins directory

type Metadata

type Metadata struct {
	Name        string   `json:"name"`
	Version     string   `json:"version"`
	APIVersion  string   `json:"api_version"`
	EventTypes  []string `json:"event_types"`
	Description string   `json:"description"`
}

Metadata describes plugin capabilities

type Registry

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

Registry manages the plugin ecosystem with isolation and versioning

func NewRegistry

func NewRegistry() *Registry

NewRegistry initializes a fresh registry

func (*Registry) Clear

func (r *Registry) Clear()

Clear removes all loaded plugins

func (*Registry) Decode

func (r *Registry) Decode(pluginName string, eventType string, data []byte) (json.RawMessage, error)

Decode uses a plugin to decode an event

func (*Registry) FindAndDecode

func (r *Registry) FindAndDecode(eventType string, data []byte) (json.RawMessage, string, error)

FindAndDecode searches for a capable plugin and decodes the event

func (*Registry) ListPlugins

func (r *Registry) ListPlugins() []Metadata

ListPlugins returns information about all loaded plugins

func (*Registry) LoadFromDirectory

func (r *Registry) LoadFromDirectory(dir string) error

LoadFromDirectory scans and loads all plugins from a directory

Jump to

Keyboard shortcuts

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