manager

package
v0.0.0-...-1e0776f Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package manager provides the plugin Manager for loading, managing, and monitoring plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handshake

func Handshake() plugin.HandshakeConfig

Handshake returns the plugin handshake configuration.

Types

type HTTPProxy

type HTTPProxy interface{}

HTTPProxy is an interface for the HTTP proxy functionality. This avoids a circular dependency with the parent plugins package.

type HostDataServer

type HostDataServer interface{}

HostDataServer is an interface for the host data server functionality.

type HostPluginsServer

type HostPluginsServer interface {
	RegisterCapability(pluginID, pluginName, capability string)
	UnregisterPlugin(pluginID string)
	UpdatePluginStatus(pluginID string, enabled, configured bool)
	HasCapability(capability string) bool
}

HostPluginsServer is an interface for the host plugins server functionality. This avoids a circular dependency with the parent plugins package.

type HostProgressServer

type HostProgressServer interface{}

HostProgressServer is an interface for the host progress server functionality.

type HostRatingsServer

type HostRatingsServer interface{}

HostRatingsServer is an interface for the host ratings server functionality.

type HostStorageServer

type HostStorageServer interface{}

HostStorageServer is an interface for the host storage server functionality.

type HostWeatherServer

type HostWeatherServer interface{}

HostWeatherServer is an interface for the host weather server functionality.

type Manager

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

Manager manages plugin lifecycle and provides access to plugin services.

func NewManager

func NewManager(cfg ManagerConfig, logger *slog.Logger) (*Manager, error)

NewManager creates a new plugin manager.

func (*Manager) DiscoverPlugins

func (m *Manager) DiscoverPlugins() ([]string, error)

DiscoverPlugins scans the plugin directory for plugin binaries. It returns a list of paths to discovered plugins.

func (*Manager) GetAllPlugins

func (m *Manager) GetAllPlugins() []*types.Instance

GetAllPlugins returns all loaded plugins.

func (*Manager) GetCapabilityRegistry

func (m *Manager) GetCapabilityRegistry() *registry.CapabilityRegistry

GetCapabilityRegistry returns the capability registry.

func (*Manager) GetEnrichers

func (m *Manager) GetEnrichers() []*types.Instance

GetEnrichers returns all plugins that implement the Enricher interface.

func (*Manager) GetHTTPProxy

func (m *Manager) GetHTTPProxy() HTTPProxy

GetHTTPProxy returns the HTTP proxy for plugin routes.

func (*Manager) GetHealthCheckInterval

func (m *Manager) GetHealthCheckInterval() time.Duration

GetHealthCheckInterval returns the health check interval.

func (*Manager) GetHostDataServer

func (m *Manager) GetHostDataServer() HostDataServer

GetHostDataServer returns the host data server.

func (*Manager) GetHostPluginsServer

func (m *Manager) GetHostPluginsServer() HostPluginsServer

GetHostPluginsServer returns the host plugins server for capability-based plugin discovery.

func (*Manager) GetHostProgressServer

func (m *Manager) GetHostProgressServer() HostProgressServer

GetHostProgressServer returns the host progress server.

func (*Manager) GetHostRatingsServer

func (m *Manager) GetHostRatingsServer() HostRatingsServer

GetHostRatingsServer returns the host ratings server.

func (*Manager) GetHostStorageServer

func (m *Manager) GetHostStorageServer() HostStorageServer

GetHostStorageServer returns the host storage server.

func (*Manager) GetHostVersion

func (m *Manager) GetHostVersion() string

GetHostVersion returns the host version string.

func (*Manager) GetHostWeatherServer

func (m *Manager) GetHostWeatherServer() HostWeatherServer

GetHostWeatherServer returns the host weather server.

func (*Manager) GetLogger

func (m *Manager) GetLogger() *slog.Logger

GetLogger returns the manager's logger.

func (*Manager) GetMaxRestarts

func (m *Manager) GetMaxRestarts() int

GetMaxRestarts returns the maximum number of restarts.

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(pluginID string) (*types.Instance, bool)

GetPlugin returns a plugin instance by ID.

func (*Manager) GetPluginDir

func (m *Manager) GetPluginDir() string

GetPluginDir returns the plugin directory path.

func (*Manager) GetProviderRegistry

func (m *Manager) GetProviderRegistry() *registry.ProviderRegistry

GetProviderRegistry returns the provider registry for provider plugins.

func (*Manager) GetPublisher

func (m *Manager) GetPublisher() domainevents.Publisher

GetPublisher returns the event publisher.

func (*Manager) GetRateLimiter

func (m *Manager) GetRateLimiter() *registry.RouteRateLimiter

GetRateLimiter returns the rate limiter.

func (*Manager) GetRouteRegistry

func (m *Manager) GetRouteRegistry() *registry.RouteRegistry

GetRouteRegistry returns the route registry.

func (*Manager) GetSearchProviderRegistry

func (m *Manager) GetSearchProviderRegistry() *registry.SearchProviderRegistry

GetSearchProviderRegistry returns the search provider registry.

func (*Manager) GetStorageDir

func (m *Manager) GetStorageDir() string

GetStorageDir returns the storage directory path.

func (*Manager) GetSystemInfo

func (m *Manager) GetSystemInfo() *pluginv1.SystemInfo

GetSystemInfo returns the system info.

func (*Manager) GetTrendingProviderRegistry

func (m *Manager) GetTrendingProviderRegistry() *registry.TrendingProviderRegistry

GetTrendingProviderRegistry returns the trending provider registry.

func (*Manager) GetWidgetRegistry

func (m *Manager) GetWidgetRegistry() *registry.WidgetRegistry

GetWidgetRegistry returns the widget registry for home screen widgets.

func (*Manager) IsPluginEnabled

func (m *Manager) IsPluginEnabled(pluginID string) bool

IsPluginEnabled returns true if the plugin exists, is loaded, and is healthy. Implements the PluginLookup interface for the HostPluginsServer.

func (*Manager) ListPlugins

func (m *Manager) ListPlugins() []*types.Instance

ListPlugins returns all loaded plugins.

func (*Manager) LoadAllPlugins

func (m *Manager) LoadAllPlugins(ctx context.Context) error

LoadAllPlugins discovers and loads all plugins in the plugin directory. It performs dependency resolution to ensure provider plugins load before plugins that depend on them.

func (*Manager) LoadPlugin

func (m *Manager) LoadPlugin(ctx context.Context, path string) (*types.Instance, error)

LoadPlugin loads a single plugin from the given path.

func (*Manager) PrintTable

func (m *Manager) PrintTable(w io.Writer, title string)

PrintTable writes a formatted table of all loaded plugins to the writer.

func (*Manager) RegisterPlugin

func (m *Manager) RegisterPlugin(id string, instance *types.Instance)

RegisterPlugin adds a plugin instance to the manager.

func (*Manager) RestartPlugin

func (m *Manager) RestartPlugin(ctx context.Context, pluginID string) error

RestartPlugin restarts a plugin by ID. This is useful when the plugin binary has been rebuilt and we need to reload it without a full server restart.

func (*Manager) SetHTTPProxy

func (m *Manager) SetHTTPProxy(proxy HTTPProxy)

SetHTTPProxy sets the HTTP proxy.

func (*Manager) SetHostDataServer

func (m *Manager) SetHostDataServer(server HostDataServer)

SetHostDataServer sets the host data server.

func (*Manager) SetHostPluginsServer

func (m *Manager) SetHostPluginsServer(server HostPluginsServer)

SetHostPluginsServer sets the host plugins server.

func (*Manager) SetPluginFactory

func (m *Manager) SetPluginFactory(factory PluginFactory)

SetPluginFactory sets the plugin factory.

func (*Manager) SetPublisher

func (m *Manager) SetPublisher(pub domainevents.Publisher)

SetPublisher sets the event publisher for plugin lifecycle events.

func (*Manager) SetSystemInfo

func (m *Manager) SetSystemInfo(info *pluginv1.SystemInfo)

SetSystemInfo sets the system information to pass to plugins during initialization. This should be called before loading plugins so they can receive hardware/system details.

func (*Manager) Shutdown

func (m *Manager) Shutdown(ctx context.Context)

Shutdown gracefully shuts down all plugins.

func (*Manager) StartHealthMonitor

func (m *Manager) StartHealthMonitor(ctx context.Context)

StartHealthMonitor starts a background goroutine that monitors plugin health.

func (*Manager) UnloadPlugin

func (m *Manager) UnloadPlugin(ctx context.Context, pluginID string) error

UnloadPlugin gracefully shuts down and removes a plugin.

func (*Manager) UnregisterPlugin

func (m *Manager) UnregisterPlugin(id string)

UnregisterPlugin removes a plugin instance from the manager.

type ManagerConfig

type ManagerConfig struct {
	// PluginDir is the directory containing plugin binaries.
	PluginDir string

	// StorageDir is the base directory for plugin data storage.
	StorageDir string

	// HostVersion is the ViewRA version for compatibility checking.
	HostVersion string

	// HealthCheckInterval is how often to check plugin health.
	// Defaults to 30 seconds if not set.
	HealthCheckInterval time.Duration

	// MaxRestarts is the maximum number of automatic restarts for a crashed plugin.
	// Defaults to 3 if not set.
	MaxRestarts int

	// HostStorageServer provides KV storage for plugins.
	// If nil, plugins will not be able to use host storage.
	HostStorageServer HostStorageServer

	// HostWeatherServer provides weather context for plugins.
	// If nil, plugins will not receive weather-based context enrichment.
	HostWeatherServer HostWeatherServer

	// HostRatingsServer provides user ratings access for plugins.
	// If nil, plugins will not be able to access user ratings.
	HostRatingsServer HostRatingsServer

	// HostProgressServer provides watch progress access for plugins.
	// If nil, plugins will not be able to access watch history.
	HostProgressServer HostProgressServer
}

ManagerConfig configures the plugin manager.

type PluginFactory

type PluginFactory interface {
	// NewPluginCoreGRPCPlugin creates a new PluginCoreGRPCPlugin.
	NewPluginCoreGRPCPlugin() plugin.Plugin

	// NewEnricherGRPCPlugin creates a new EnricherGRPCPlugin.
	NewEnricherGRPCPlugin() plugin.Plugin

	// NewPluginProviderGRPCPlugin creates a new PluginProviderGRPCPlugin.
	NewPluginProviderGRPCPlugin() plugin.Plugin

	// NewHostDataGRPCPlugin creates a new HostDataGRPCPlugin.
	NewHostDataGRPCPlugin(impl HostDataServer, logger *slog.Logger) plugin.Plugin

	// NewHostStorageGRPCPlugin creates a new HostStorageGRPCPlugin.
	NewHostStorageGRPCPlugin(impl HostStorageServer, pluginID string, logger *slog.Logger) plugin.Plugin

	// NewHostWeatherGRPCPlugin creates a new HostWeatherGRPCPlugin.
	NewHostWeatherGRPCPlugin(impl HostWeatherServer, logger *slog.Logger) plugin.Plugin

	// NewHostPluginsGRPCPlugin creates a new HostPluginsGRPCPlugin.
	NewHostPluginsGRPCPlugin(impl HostPluginsServer, logger *slog.Logger) plugin.Plugin

	// NewHostRatingsGRPCPlugin creates a new HostRatingsGRPCPlugin.
	NewHostRatingsGRPCPlugin(impl HostRatingsServer, logger *slog.Logger) plugin.Plugin

	// NewHostProgressGRPCPlugin creates a new HostProgressGRPCPlugin.
	NewHostProgressGRPCPlugin(impl HostProgressServer, logger *slog.Logger) plugin.Plugin

	// NewVectorSearchGRPCPlugin creates a new VectorSearchGRPCPlugin for client-side dispensing.
	NewVectorSearchGRPCPlugin() plugin.Plugin

	// NewTrendingProviderGRPCPlugin creates a new TrendingProviderGRPCPlugin for client-side dispensing.
	NewTrendingProviderGRPCPlugin() plugin.Plugin

	// GetBrokerID extracts the broker ID from a dispensed broker info struct.
	GetBrokerID(brokerInfo interface{}) uint32
}

PluginFactory creates go-plugin Plugin instances. This interface allows the manager package to create plugins without importing the parent plugins package, avoiding circular dependencies.

Jump to

Keyboard shortcuts

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