plugin

package
v0.0.0-...-58f0ab6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeCloudProvider = "cloud-provider"
)

Plugin types

Variables

View Source
var Registry = NewPluginRegistry()

Global registry instance

Functions

func LoadExternalPlugins

func LoadExternalPlugins(dir string) error

LoadExternalPlugins loads plugins from the specified directory and registers them

Types

type ExternalPlugin

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

ExternalPlugin provides access to dynamically loaded Go plugins

func LoadPluginFromFile

func LoadPluginFromFile(path string) (*ExternalPlugin, error)

LoadPluginFromFile loads a plugin from a Go plugin file (.so)

type Plugin

type Plugin interface {
	// Info returns plugin metadata
	Info() PluginInfo

	// Init initializes the plugin with configuration
	Init(config interface{}) error

	// Start starts the plugin
	Start() error

	// Stop gracefully stops the plugin
	Stop() error

	// IsRunning returns true if the plugin is running
	IsRunning() bool
}

Plugin defines the base interface all plugins must implement

func LoadPluginsFromDir

func LoadPluginsFromDir(dir string) ([]Plugin, error)

LoadPluginsFromDir loads all plugins from a directory

func LoadPluginsFromManifest

func LoadPluginsFromManifest(dir string) ([]Plugin, error)

LoadPluginsFromManifest loads plugins based on manifest files

type PluginInfo

type PluginInfo struct {
	ID           string          // Unique identifier
	Name         string          // Human-readable name
	Type         string          // Plugin type (e.g., "cloud-provider")
	Version      string          // Version string
	Capabilities map[string]bool // Capabilities this plugin supports
	Author       string          // Plugin author
	Website      string          // Plugin website or repository
	Dependencies []string        // IDs of plugins this plugin depends on
}

PluginInfo contains metadata about a plugin

type PluginRegistry

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

PluginRegistry is the global registry of plugins

func NewPluginRegistry

func NewPluginRegistry() *PluginRegistry

NewPluginRegistry creates a new plugin registry

func (*PluginRegistry) Get

func (r *PluginRegistry) Get(id string) (Plugin, bool)

Get returns a plugin by ID

func (*PluginRegistry) GetByType

func (r *PluginRegistry) GetByType(pluginType string) []Plugin

GetByType returns all plugins of a specific type

func (*PluginRegistry) Register

func (r *PluginRegistry) Register(p Plugin) error

Register adds a plugin to the registry

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

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