Documentation
¶
Overview ¶
Package plugins provides a dynamic plugin system for revoco.
This file handles embedding and extraction of default plugins that are bundled with the revoco binary and auto-extracted on first run.
Package plugins provides a dynamic plugin system for revoco.
This file handles plugin installation, removal, and updates from the plugin registry hosted on the GitHub plugins branch.
Package plugins provides a dynamic plugin system for revoco.
This file contains the integration layer that bridges the plugin system with revoco's existing connector, processor, and output registries.
Package plugins provides a dynamic plugin system for revoco.
The plugin system supports two tiers:
- Lua plugins: Sandboxed, single-file plugins for most use cases
- External plugins: Any language via JSON-RPC for complex integrations
Plugin types: Connector, Processor, Output
Index ¶
- Constants
- Variables
- func ApplyDefaults(schema []ConfigOption, settings map[string]any) map[string]any
- func ConfigPath() string
- func DefaultPluginDirs() []string
- func EnsurePluginDirs() error
- func ExtractDefaultPlugins(destDir string) error
- func ForceExtractDefaultPlugins(destDir string) error
- func FormatInstallInstructions(dep BinaryDependency) string
- func GetDefaultPluginContent(name string) ([]byte, error)
- func GetInstallCommand(dep BinaryDependency) (string, string)
- func InitializePlugins(ctx context.Context, opts ...ManagerOption) error
- func InstallDependency(dep BinaryDependency) error
- func IsLuaError(err error) bool
- func IsMissingDependency(err error) bool
- func IsPluginError(err error, pluginID string) bool
- func IsRPCError(err error) bool
- func ListDefaultPlugins() ([]string, error)
- func RegisterExternalPluginFactory(factory PluginFactory)
- func RegisterLuaPluginFactory(factory PluginFactory)
- func RegisterPlugin(p Plugin) error
- func ResetDefaultPlugins(destDir string) error
- func SaveConfig(cfg *Config) error
- func SaveConfigTo(cfg *Config, path string) error
- func ShutdownPlugins() error
- func ValidatePluginConfig(plugin Plugin, settings map[string]any) error
- type BinaryDependency
- type Config
- func (c *Config) Disable(pluginID string)
- func (c *Config) Enable(pluginID string)
- func (c *Config) GetPluginSetting(pluginID, key string) (any, bool)
- func (c *Config) GetPluginSettings(pluginID string) map[string]any
- func (c *Config) IsDisabled(pluginID string) bool
- func (c *Config) SetPluginSetting(pluginID, key string, value any)
- func (c *Config) SetPluginSettings(pluginID string, settings map[string]any)
- func (c *Config) Validate() error
- type ConfigError
- type ConfigOption
- type ConnectorPlugin
- type DependencyChecker
- func (c *DependencyChecker) AllSatisfied(deps []BinaryDependency) bool
- func (c *DependencyChecker) Check(dep BinaryDependency) *DependencyStatus
- func (c *DependencyChecker) CheckAll(deps []BinaryDependency) []*DependencyStatus
- func (c *DependencyChecker) ClearCache()
- func (c *DependencyChecker) MissingDependencies(deps []BinaryDependency) []BinaryDependency
- type DependencyError
- type DependencyStatus
- type DiscoveredPlugin
- type ExternalManifest
- type ExternalManifestMeta
- type ExternalManifestSpec
- type ExternalRuntime
- type ExternalSetup
- type InstalledPlugin
- type InstalledPluginsDB
- type Installer
- func (i *Installer) CheckUpdates(ctx context.Context) ([]PluginUpdate, error)
- func (i *Installer) FetchIndex(ctx context.Context) (*RegistryIndex, error)
- func (i *Installer) GetEntry(ctx context.Context, id string) (*RegistryEntry, error)
- func (i *Installer) GetInstalled(id string) (*InstalledPlugin, error)
- func (i *Installer) Install(ctx context.Context, id string) error
- func (i *Installer) InstallFromPath(ctx context.Context, path string) error
- func (i *Installer) InstallFromURL(ctx context.Context, url string) error
- func (i *Installer) ListInstalled() ([]InstalledPlugin, error)
- func (i *Installer) Remove(ctx context.Context, id string) error
- func (i *Installer) Search(ctx context.Context, query string) ([]RegistryEntry, error)
- func (i *Installer) Update(ctx context.Context, id string) error
- func (i *Installer) UpdateAll(ctx context.Context) ([]string, error)
- type InstallerOption
- type Loader
- type LuaError
- type LuaPluginMeta
- type Manager
- func (m *Manager) CheckDependencies() []*DependencyStatus
- func (m *Manager) GetApplicableProcessors(item *core.DataItem) []Processor
- func (m *Manager) GetConnector(id string) (core.Connector, bool)
- func (m *Manager) GetOutput(id string) (svccore.Output, bool)
- func (m *Manager) GetProcessor(id string) (Processor, bool)
- func (m *Manager) Initialize(ctx context.Context) error
- func (m *Manager) ListPlugins() []PluginInfo
- func (m *Manager) Registry() *Registry
- func (m *Manager) ReloadPlugin(ctx context.Context, id string) error
- func (m *Manager) Shutdown() error
- type ManagerOption
- type ManifestError
- type OutputPlugin
- type Plugin
- type PluginConfig
- type PluginError
- type PluginFactory
- type PluginInfo
- type PluginReader
- type PluginSource
- type PluginState
- type PluginTier
- type PluginType
- type PluginUpdate
- type Processor
- type ProcessorPlugin
- type ProgressFunc
- type RPCCallError
- type RPCError
- type RPCRequest
- type RPCResponse
- type Registry
- func (r *Registry) All() []Plugin
- func (r *Registry) Connectors() []ConnectorPlugin
- func (r *Registry) ConnectorsByCapability(cap string) []ConnectorPlugin
- func (r *Registry) Get(id string) (Plugin, bool)
- func (r *Registry) GetConnector(id string) (ConnectorPlugin, bool)
- func (r *Registry) GetOutput(id string) (OutputPlugin, bool)
- func (r *Registry) GetProcessor(id string) (ProcessorPlugin, bool)
- func (r *Registry) LoadAll(ctx context.Context) error
- func (r *Registry) OnLoad(cb func(Plugin))
- func (r *Registry) OnReload(cb func(Plugin))
- func (r *Registry) OnUnload(cb func(Plugin))
- func (r *Registry) Outputs() []OutputPlugin
- func (r *Registry) PluginsByState(state PluginState) []Plugin
- func (r *Registry) PluginsByTier(tier PluginTier) []Plugin
- func (r *Registry) Processors() []ProcessorPlugin
- func (r *Registry) ProcessorsByDataType(dt string) []ProcessorPlugin
- func (r *Registry) Register(p Plugin) error
- func (r *Registry) Reload(ctx context.Context, id string) error
- func (r *Registry) Stats() RegistryStats
- func (r *Registry) UnloadAll() error
- func (r *Registry) Unregister(id string) error
- type RegistryEntry
- type RegistryIndex
- type RegistryStats
- type Selector
- type SelectorError
- type SelectorMatcher
- type WatchOp
Constants ¶
const DefaultPluginsVersion = "2"
DefaultPluginsVersion is the version of the default plugins bundle. Increment this when default plugins are updated to trigger re-extraction.
const DefaultRegistryURL = "https://raw.githubusercontent.com/fulgidus/revoco/plugins"
DefaultRegistryURL is the default URL for the plugin registry.
const IndexCacheDuration = 15 * time.Minute
IndexCacheDuration is how long to cache the registry index.
Variables ¶
var ( ErrPluginNotFound = errors.New("plugin not found") ErrPluginAlreadyLoaded = errors.New("plugin already loaded") ErrPluginLoadFailed = errors.New("plugin load failed") ErrPluginDisabled = errors.New("plugin is disabled") ErrPluginTypeMismatch = errors.New("plugin type mismatch") ErrInvalidManifest = errors.New("invalid plugin manifest") ErrMissingDependency = errors.New("missing binary dependency") ErrRuntimeNotFound = errors.New("runtime not found") ErrSelectorInvalid = errors.New("invalid selector") ErrProcessingFailed = errors.New("processing failed") ErrConnectionFailed = errors.New("connection failed") ErrConfigInvalid = errors.New("invalid configuration") )
Common plugin errors.
var CommonRuntimes = map[string]ExternalRuntime{
"python3": {
Command: "python3",
MinVersion: "3.8",
VersionCheck: "python3 --version",
},
"python": {
Command: "python",
MinVersion: "3.8",
VersionCheck: "python --version",
},
"node": {
Command: "node",
MinVersion: "16.0",
VersionCheck: "node --version",
},
"ruby": {
Command: "ruby",
MinVersion: "2.7",
VersionCheck: "ruby --version",
},
"go": {
Command: "go",
MinVersion: "1.20",
VersionCheck: "go version",
},
}
CommonRuntimes contains common runtime configurations.
Functions ¶
func ApplyDefaults ¶
func ApplyDefaults(schema []ConfigOption, settings map[string]any) map[string]any
ApplyDefaults applies default values to a settings map.
func DefaultPluginDirs ¶
func DefaultPluginDirs() []string
DefaultPluginDirs returns the default plugin directories.
func EnsurePluginDirs ¶
func EnsurePluginDirs() error
EnsurePluginDirs creates the plugin directory structure if it doesn't exist.
func ExtractDefaultPlugins ¶
ExtractDefaultPlugins extracts bundled default plugins to the user's plugin directory. It only extracts if this is the first run (marker file doesn't exist) or if the plugin version has changed.
func ForceExtractDefaultPlugins ¶
ForceExtractDefaultPlugins extracts default plugins, overwriting existing files. Use with caution - this will overwrite any user modifications to default plugins.
func FormatInstallInstructions ¶
func FormatInstallInstructions(dep BinaryDependency) string
FormatInstallInstructions returns human-readable installation instructions.
func GetDefaultPluginContent ¶
GetDefaultPluginContent returns the content of an embedded default plugin.
func GetInstallCommand ¶
func GetInstallCommand(dep BinaryDependency) (string, string)
GetInstallCommand returns the install command for the current OS/package manager.
func InitializePlugins ¶
func InitializePlugins(ctx context.Context, opts ...ManagerOption) error
InitializePlugins initializes the global plugin manager.
func InstallDependency ¶
func InstallDependency(dep BinaryDependency) error
InstallDependency attempts to install a dependency.
func IsLuaError ¶
IsLuaError checks if err is a Lua execution error.
func IsMissingDependency ¶
IsMissingDependency checks if err is a missing dependency error.
func IsPluginError ¶
IsPluginError checks if err is a PluginError for the given plugin.
func ListDefaultPlugins ¶
ListDefaultPlugins returns information about the embedded default plugins.
func RegisterExternalPluginFactory ¶
func RegisterExternalPluginFactory(factory PluginFactory)
RegisterExternalPluginFactory registers the external plugin factory. This is called by the external package during initialization.
func RegisterLuaPluginFactory ¶
func RegisterLuaPluginFactory(factory PluginFactory)
RegisterLuaPluginFactory registers the Lua plugin factory. This is called by the lua package during initialization.
func RegisterPlugin ¶
Register registers a plugin with the global registry.
func ResetDefaultPlugins ¶
ResetDefaultPlugins removes the marker file, causing defaults to be re-extracted on next run. Existing plugins are NOT removed.
func SaveConfig ¶
SaveConfig saves the plugin configuration to the default path.
func SaveConfigTo ¶
SaveConfigTo saves the plugin configuration to a specific path.
func ShutdownPlugins ¶
func ShutdownPlugins() error
ShutdownPlugins shuts down the global plugin manager.
Types ¶
type BinaryDependency ¶
type BinaryDependency struct {
Binary string `json:"binary"` // Binary name (e.g., "ffmpeg")
Check string `json:"check"` // Command to verify (e.g., "ffmpeg -version")
VersionRegex string `json:"version_regex"` // Regex to extract version
MinVersion string `json:"min_version"` // Minimum required version
Install map[string]string `json:"install"` // Package manager -> install command
// Runtime state (not serialized)
Found bool `json:"-"`
Version string `json:"-"`
}
BinaryDependency describes an external binary required by a plugin.
type Config ¶
type Config struct {
// Plugin directories to scan
PluginDirs []string `json:"plugin_dirs,omitempty"`
// Disabled plugins (by ID)
Disabled []string `json:"disabled,omitempty"`
// Plugin-specific settings
PluginSettings map[string]map[string]any `json:"plugin_settings,omitempty"`
// Hot-reload enabled
HotReload bool `json:"hot_reload,omitempty"`
}
Config holds the plugin system configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default plugin configuration.
func LoadConfig ¶
LoadConfig loads the plugin configuration from the default path.
func LoadConfigFrom ¶
LoadConfigFrom loads the plugin configuration from a specific path.
func (*Config) GetPluginSetting ¶
GetPluginSetting returns a specific setting for a plugin.
func (*Config) GetPluginSettings ¶
GetPluginSettings returns settings for a specific plugin.
func (*Config) IsDisabled ¶
IsDisabled checks if a plugin is disabled.
func (*Config) SetPluginSetting ¶
SetPluginSetting sets a specific setting for a plugin.
func (*Config) SetPluginSettings ¶
SetPluginSettings sets settings for a specific plugin.
type ConfigError ¶
ConfigError represents a configuration validation error.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type ConfigOption ¶
type ConfigOption struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"` // bool, string, int, float, select, path, password
Default any `json:"default,omitempty"`
Options []string `json:"options,omitempty"` // For select type
Required bool `json:"required,omitempty"`
Sensitive bool `json:"sensitive,omitempty"` // If true, mask in UI
}
ConfigOption describes a configurable setting for a plugin.
type ConnectorPlugin ¶
type ConnectorPlugin interface {
Plugin
// AsConnector returns the base connector interface.
AsConnector() core.Connector
// AsReader returns the reader interface if supported.
AsReader() (core.ConnectorReader, bool)
// AsWriter returns the writer interface if supported.
AsWriter() (core.ConnectorWriter, bool)
// AsTester returns the tester interface if supported.
AsTester() (core.ConnectorTester, bool)
}
ConnectorPlugin wraps a dynamically-loaded connector.
func GetConnectorPlugin ¶
func GetConnectorPlugin(id string) (ConnectorPlugin, bool)
GetConnectorPlugin returns a connector plugin from the global registry.
type DependencyChecker ¶
type DependencyChecker struct {
// contains filtered or unexported fields
}
DependencyChecker verifies binary dependencies for plugins.
func NewDependencyChecker ¶
func NewDependencyChecker() *DependencyChecker
NewDependencyChecker creates a new dependency checker.
func (*DependencyChecker) AllSatisfied ¶
func (c *DependencyChecker) AllSatisfied(deps []BinaryDependency) bool
AllSatisfied returns true if all dependencies are satisfied.
func (*DependencyChecker) Check ¶
func (c *DependencyChecker) Check(dep BinaryDependency) *DependencyStatus
Check verifies a single dependency.
func (*DependencyChecker) CheckAll ¶
func (c *DependencyChecker) CheckAll(deps []BinaryDependency) []*DependencyStatus
CheckAll verifies all dependencies for a plugin.
func (*DependencyChecker) ClearCache ¶
func (c *DependencyChecker) ClearCache()
ClearCache clears the dependency cache.
func (*DependencyChecker) MissingDependencies ¶
func (c *DependencyChecker) MissingDependencies(deps []BinaryDependency) []BinaryDependency
MissingDependencies returns all unsatisfied dependencies.
type DependencyError ¶
DependencyError wraps an error with dependency context.
func (*DependencyError) Error ¶
func (e *DependencyError) Error() string
type DependencyStatus ¶
type DependencyStatus struct {
Binary string
Found bool
Path string
Version string
MeetsMin bool
MinNeeded string
Error string
}
DependencyStatus holds the status of a binary dependency.
func CheckRuntime ¶
func CheckRuntime(rt ExternalRuntime) *DependencyStatus
CheckRuntime verifies that a runtime is available.
type DiscoveredPlugin ¶
type DiscoveredPlugin struct {
Path string
Type PluginType
Tier PluginTier
Info *PluginInfo
Manifest *ExternalManifest
Source PluginSource
Error string
}
DiscoveredPlugin represents a plugin found during discovery.
type ExternalManifest ¶
type ExternalManifest struct {
APIVersion string `json:"apiVersion"` // e.g., "revoco/v1"
Kind string `json:"kind"` // "ExternalPlugin"
Metadata ExternalManifestMeta `json:"metadata"`
Spec ExternalManifestSpec `json:"spec"`
}
ExternalManifest is the manifest.json structure for external plugins.
type ExternalManifestMeta ¶
type ExternalManifestMeta struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
Author string `json:"author,omitempty"`
}
ExternalManifestMeta contains plugin identity information.
type ExternalManifestSpec ¶
type ExternalManifestSpec struct {
Type PluginType `json:"type"` // connector, processor, output
Runtime ExternalRuntime `json:"runtime"`
Entrypoint string `json:"entrypoint"`
Setup *ExternalSetup `json:"setup,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
DataTypes []string `json:"dataTypes,omitempty"`
RequiresAuth bool `json:"requiresAuth,omitempty"`
AuthType string `json:"authType,omitempty"`
ConfigSchema []ConfigOption `json:"configSchema,omitempty"`
DefaultSelector *Selector `json:"defaultSelector,omitempty"`
Dependencies []BinaryDependency `json:"dependencies,omitempty"`
}
ExternalManifestSpec contains plugin specification.
type ExternalRuntime ¶
type ExternalRuntime struct {
Command string `json:"command"` // e.g., "python3"
MinVersion string `json:"minVersion"` // e.g., "3.9"
VersionCheck string `json:"versionCheck"` // e.g., "python3 --version"
}
ExternalRuntime describes the runtime requirements.
type ExternalSetup ¶
type ExternalSetup struct {
Command string `json:"command"` // e.g., "pip install -r requirements.txt"
RunWhen string `json:"runWhen"` // File to check for changes (e.g., "requirements.txt")
}
ExternalSetup describes setup requirements.
type InstalledPlugin ¶
type InstalledPlugin struct {
Entry RegistryEntry `json:"entry"`
InstalledAt time.Time `json:"installed_at"`
UpdatedAt time.Time `json:"updated_at"`
Source string `json:"source"` // "registry", "local", "url"
SourcePath string `json:"source_path"`
LocalPath string `json:"local_path"`
}
InstalledPlugin represents a locally installed plugin.
type InstalledPluginsDB ¶
type InstalledPluginsDB struct {
Version string `json:"version"`
Plugins map[string]InstalledPlugin `json:"plugins"`
UpdatedAt time.Time `json:"updated_at"`
}
InstalledPluginsDB tracks installed plugins.
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer handles plugin installation and management.
func NewInstaller ¶
func NewInstaller(opts ...InstallerOption) *Installer
NewInstaller creates a new plugin installer.
func (*Installer) CheckUpdates ¶
func (i *Installer) CheckUpdates(ctx context.Context) ([]PluginUpdate, error)
CheckUpdates checks for available plugin updates.
func (*Installer) FetchIndex ¶
func (i *Installer) FetchIndex(ctx context.Context) (*RegistryIndex, error)
FetchIndex fetches the plugin registry index.
func (*Installer) GetInstalled ¶
func (i *Installer) GetInstalled(id string) (*InstalledPlugin, error)
GetInstalled returns information about an installed plugin.
func (*Installer) InstallFromPath ¶
InstallFromPath installs a plugin from a local path.
func (*Installer) InstallFromURL ¶
InstallFromURL installs a plugin from a URL.
func (*Installer) ListInstalled ¶
func (i *Installer) ListInstalled() ([]InstalledPlugin, error)
ListInstalled returns all installed plugins.
type InstallerOption ¶
type InstallerOption func(*Installer)
InstallerOption configures the installer.
func WithCacheDir ¶
func WithCacheDir(dir string) InstallerOption
WithCacheDir sets a custom cache directory.
func WithPluginDir ¶
func WithPluginDir(dir string) InstallerOption
WithPluginDir sets a custom plugin directory.
func WithRegistryURL ¶
func WithRegistryURL(url string) InstallerOption
WithRegistryURL sets a custom registry URL.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader discovers and loads plugins from directories.
func (*Loader) Discover ¶
func (l *Loader) Discover(dir string) ([]*DiscoveredPlugin, error)
Discover scans a directory for plugins.
func (*Loader) DiscoverAll ¶
func (l *Loader) DiscoverAll() ([]*DiscoveredPlugin, error)
DiscoverAll scans all plugin directories and returns discovered plugins.
type LuaPluginMeta ¶
type LuaPluginMeta struct {
ID string `lua:"id"`
Name string `lua:"name"`
Description string `lua:"description"`
Version string `lua:"version"`
Type string `lua:"type"` // connector, processor, output
Capabilities []string `lua:"capabilities,omitempty"`
DataTypes []string `lua:"data_types,omitempty"`
RequiresAuth bool `lua:"requires_auth,omitempty"`
AuthType string `lua:"auth_type,omitempty"`
}
LuaPluginMeta represents the Plugin table in a Lua plugin.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles plugin discovery, loading, and integration with revoco.
func NewManager ¶
func NewManager(opts ...ManagerOption) *Manager
NewManager creates a new plugin manager.
func (*Manager) CheckDependencies ¶
func (m *Manager) CheckDependencies() []*DependencyStatus
CheckDependencies checks binary dependencies for all plugins.
func (*Manager) GetApplicableProcessors ¶
GetApplicableProcessors returns all processors that can handle the given item.
func (*Manager) GetConnector ¶
GetConnector returns a connector by ID (checks both plugins and built-in).
func (*Manager) GetProcessor ¶
GetProcessor returns a processor plugin by ID.
func (*Manager) Initialize ¶
Initialize discovers and loads all plugins. This method is idempotent - calling it multiple times is safe.
func (*Manager) ListPlugins ¶
func (m *Manager) ListPlugins() []PluginInfo
ListPlugins returns information about all loaded plugins.
func (*Manager) ReloadPlugin ¶
ReloadPlugin reloads a specific plugin by ID.
type ManagerOption ¶
type ManagerOption func(*Manager)
ManagerOption configures the plugin manager.
func WithHotReload ¶
func WithHotReload(enabled bool) ManagerOption
WithHotReload enables or disables hot-reload for Lua plugins.
func WithLogLevel ¶
func WithLogLevel(level string) ManagerOption
WithLogLevel sets the log level for plugin operations.
func WithPluginDirs ¶
func WithPluginDirs(dirs ...string) ManagerOption
WithPluginDirs sets the directories to search for plugins.
type ManifestError ¶
ManifestError wraps an error in manifest parsing/validation.
func (*ManifestError) Error ¶
func (e *ManifestError) Error() string
type OutputPlugin ¶
type OutputPlugin interface {
Plugin
// AsOutput returns the output interface.
AsOutput() svccore.Output
// Selector returns the default selector for this output.
Selector() *Selector
}
OutputPlugin wraps a dynamically-loaded output.
func GetOutputPlugin ¶
func GetOutputPlugin(id string) (OutputPlugin, bool)
GetOutputPlugin returns an output plugin from the global registry.
type Plugin ¶
type Plugin interface {
// Info returns the plugin metadata.
Info() PluginInfo
// Load initializes the plugin. Called once when discovered.
Load(ctx context.Context) error
// Unload releases any resources held by the plugin.
Unload() error
// Reload reloads the plugin (for hot-reload support).
Reload(ctx context.Context) error
}
Plugin is the base interface for all plugins.
type PluginConfig ¶
type PluginConfig struct {
PluginID string `json:"plugin_id"`
Enabled bool `json:"enabled"`
Settings map[string]any `json:"settings"`
Selector *Selector `json:"selector,omitempty"`
}
PluginConfig holds configuration for a plugin instance.
type PluginError ¶
PluginError wraps an error with plugin context.
func NewPluginError ¶
func NewPluginError(pluginID, op string, err error) *PluginError
NewPluginError creates a new PluginError.
func (*PluginError) Error ¶
func (e *PluginError) Error() string
func (*PluginError) Unwrap ¶
func (e *PluginError) Unwrap() error
type PluginFactory ¶
type PluginFactory func(dp *DiscoveredPlugin) (Plugin, error)
PluginFactory creates a Plugin from discovered metadata.
type PluginInfo ¶
type PluginInfo struct {
// Identity
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Author string `json:"author,omitempty"`
// Classification
Type PluginType `json:"type"`
Tier PluginTier `json:"tier"`
Source PluginSource `json:"source"`
// Location
Path string `json:"path"` // File path or directory
// State
State PluginState `json:"state"`
StateError string `json:"state_error,omitempty"`
// Capabilities (for connectors)
Capabilities []core.ConnectorCapability `json:"capabilities,omitempty"`
DataTypes []core.DataType `json:"data_types,omitempty"`
RequiresAuth bool `json:"requires_auth,omitempty"`
AuthType string `json:"auth_type,omitempty"`
// Configuration
ConfigSchema []ConfigOption `json:"config_schema,omitempty"`
// Dependencies
Dependencies []BinaryDependency `json:"dependencies,omitempty"`
// Default selector (for processors and outputs)
DefaultSelector *Selector `json:"default_selector,omitempty"`
}
PluginInfo contains metadata about a plugin.
type PluginReader ¶
type PluginReader struct {
io.ReadCloser
Plugin Plugin
Item *core.DataItem
}
PluginReader wraps io.ReadCloser with plugin context.
type PluginSource ¶
type PluginSource string
PluginSource identifies where the plugin came from.
const ( PluginSourceBuiltIn PluginSource = "builtin" // Shipped with revoco PluginSourceUser PluginSource = "user" // User's plugin directory PluginSourceCommunity PluginSource = "community" // Future: community repository )
type PluginState ¶
type PluginState string
PluginState represents the current state of a plugin.
const ( PluginStateUnloaded PluginState = "unloaded" // Not yet loaded PluginStateLoading PluginState = "loading" // Currently loading PluginStateReady PluginState = "ready" // Loaded and ready PluginStateMissingDeps PluginState = "missing_deps" // Missing binary dependencies PluginStateError PluginState = "error" // Failed to load PluginStateDisabled PluginState = "disabled" // Disabled by user )
type PluginTier ¶
type PluginTier string
PluginTier identifies how the plugin is executed.
const ( PluginTierLua PluginTier = "lua" // Embedded Lua interpreter PluginTierExternal PluginTier = "external" // External process via JSON-RPC )
type PluginType ¶
type PluginType string
PluginType identifies the kind of plugin.
const ( PluginTypeConnector PluginType = "connector" PluginTypeProcessor PluginType = "processor" PluginTypeOutput PluginType = "output" )
type PluginUpdate ¶
type PluginUpdate struct {
ID string
CurrentVersion string
LatestVersion string
Entry RegistryEntry
}
PluginUpdate represents an available plugin update.
type Processor ¶
type Processor interface {
// Identity
ID() string
Name() string
Description() string
// Configuration
ConfigSchema() []ConfigOption
// Selector
DefaultSelector() *Selector
// Processing
CanProcess(item *core.DataItem) bool
Process(ctx context.Context, item *core.DataItem, config map[string]any) (*core.DataItem, error)
ProcessBatch(ctx context.Context, items []*core.DataItem, config map[string]any, progress ProgressFunc) ([]*core.DataItem, error)
}
Processor is the interface for data processors. This extends the service-level processor with plugin-specific features.
type ProcessorPlugin ¶
type ProcessorPlugin interface {
Plugin
// AsProcessor returns the processor interface.
AsProcessor() Processor
// Selector returns the default selector for this processor.
Selector() *Selector
}
ProcessorPlugin wraps a dynamically-loaded processor.
func GetProcessorPlugin ¶
func GetProcessorPlugin(id string) (ProcessorPlugin, bool)
GetProcessorPlugin returns a processor plugin from the global registry.
type ProgressFunc ¶
ProgressFunc reports progress during processing.
type RPCCallError ¶
RPCCallError wraps an error from an external plugin RPC call.
func (*RPCCallError) Error ¶
func (e *RPCCallError) Error() string
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
RPCError is a JSON-RPC 2.0 error.
type RPCRequest ¶
type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id,omitempty"`
Method string `json:"method"`
Params map[string]any `json:"params,omitempty"`
}
RPCRequest is a JSON-RPC 2.0 request.
type RPCResponse ¶
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id,omitempty"`
Result any `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
RPCResponse is a JSON-RPC 2.0 response.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all loaded plugins.
func (*Registry) Connectors ¶
func (r *Registry) Connectors() []ConnectorPlugin
Connectors returns all connector plugins.
func (*Registry) ConnectorsByCapability ¶
func (r *Registry) ConnectorsByCapability(cap string) []ConnectorPlugin
ConnectorsByCapability returns connectors with the given capability.
func (*Registry) GetConnector ¶
func (r *Registry) GetConnector(id string) (ConnectorPlugin, bool)
GetConnector returns a connector plugin by ID.
func (*Registry) GetOutput ¶
func (r *Registry) GetOutput(id string) (OutputPlugin, bool)
GetOutput returns an output plugin by ID.
func (*Registry) GetProcessor ¶
func (r *Registry) GetProcessor(id string) (ProcessorPlugin, bool)
GetProcessor returns a processor plugin by ID.
func (*Registry) Outputs ¶
func (r *Registry) Outputs() []OutputPlugin
Outputs returns all output plugins.
func (*Registry) PluginsByState ¶
func (r *Registry) PluginsByState(state PluginState) []Plugin
PluginsByState returns plugins in the given state.
func (*Registry) PluginsByTier ¶
func (r *Registry) PluginsByTier(tier PluginTier) []Plugin
PluginsByTier returns plugins of the given tier.
func (*Registry) Processors ¶
func (r *Registry) Processors() []ProcessorPlugin
Processors returns all processor plugins.
func (*Registry) ProcessorsByDataType ¶
func (r *Registry) ProcessorsByDataType(dt string) []ProcessorPlugin
ProcessorsByDataType returns processors that handle the given data type.
func (*Registry) Stats ¶
func (r *Registry) Stats() RegistryStats
Stats returns registry statistics.
func (*Registry) Unregister ¶
Unregister removes a plugin from the registry.
type RegistryEntry ¶
type RegistryEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Author string `json:"author"`
Version string `json:"version"`
Type PluginType `json:"type"`
Tier PluginTier `json:"tier"`
Tags []string `json:"tags,omitempty"`
Homepage string `json:"homepage,omitempty"`
Repository string `json:"repository,omitempty"`
License string `json:"license,omitempty"`
Downloads int `json:"downloads,omitempty"`
Path string `json:"path"` // Path within the plugins branch
Checksum string `json:"checksum,omitempty"`
Platforms []string `json:"platforms,omitempty"` // e.g., ["linux", "darwin", "windows"]
MinVersion string `json:"min_version,omitempty"` // Minimum revoco version
Deprecated bool `json:"deprecated,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
RegistryEntry represents a plugin entry in the registry.
type RegistryIndex ¶
type RegistryIndex struct {
Version string `json:"version"`
LastUpdated time.Time `json:"last_updated"`
Plugins map[string]RegistryEntry `json:"plugins"`
}
RegistryIndex represents the plugin registry index.json file.
type RegistryStats ¶
type RegistryStats struct {
Total int
Connectors int
Processors int
Outputs int
ByTier map[PluginTier]int
ByState map[PluginState]int
}
RegistryStats contains registry statistics.
type Selector ¶
type Selector struct {
// By data type
DataTypes []core.DataType `json:"data_types,omitempty" yaml:"data_types,omitempty"`
// By file extension (e.g., ".jpg", ".png")
Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty"`
// By MIME type (supports wildcards like "image/*")
MimeTypes []string `json:"mime_types,omitempty" yaml:"mime_types,omitempty"`
// By source connector ID
SourceConnectors []string `json:"source_connectors,omitempty" yaml:"source_connectors,omitempty"`
// By path pattern (glob)
PathMatch string `json:"path_match,omitempty" yaml:"path_match,omitempty"`
PathExclude string `json:"path_exclude,omitempty" yaml:"path_exclude,omitempty"`
// By metadata condition (Lua expression evaluated at runtime)
Condition string `json:"condition,omitempty" yaml:"condition,omitempty"`
// Chain from another job's output
From string `json:"from,omitempty" yaml:"from,omitempty"`
// Select all items (overrides other filters)
All bool `json:"all,omitempty" yaml:"all,omitempty"`
}
Selector defines criteria for matching data items. Selectors can filter items by type, extension, path, metadata, etc.
func MergeSelectors ¶
MergeSelectors merges multiple selectors into one. Later selectors override earlier ones for non-slice fields.
type SelectorError ¶
SelectorError wraps an error with selector field context.
func (*SelectorError) Error ¶
func (e *SelectorError) Error() string
func (*SelectorError) Unwrap ¶
func (e *SelectorError) Unwrap() error
type SelectorMatcher ¶
type SelectorMatcher struct {
// contains filtered or unexported fields
}
SelectorMatcher provides methods to match items against a selector.
func NewSelectorMatcher ¶
func NewSelectorMatcher(s *Selector) (*SelectorMatcher, error)
NewSelectorMatcher creates a new matcher for the given selector.
func (*SelectorMatcher) Match ¶
func (m *SelectorMatcher) Match(item *core.DataItem) bool
Match checks if an item matches the selector criteria. Note: Condition evaluation requires Lua runtime and is handled separately.
func (*SelectorMatcher) MatchWithCondition ¶
func (m *SelectorMatcher) MatchWithCondition(item *core.DataItem, conditionEvaluator func(item *core.DataItem, condition string) (bool, error)) (bool, error)
MatchWithCondition checks if an item matches, including Lua condition evaluation. The conditionEvaluator is a function that evaluates the Lua condition.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package external provides the external plugin runtime for revoco.
|
Package external provides the external plugin runtime for revoco. |
|
Package lua provides the Lua runtime for revoco plugins.
|
Package lua provides the Lua runtime for revoco plugins. |
|
Package pipeline provides the pipeline engine for revoco.
|
Package pipeline provides the pipeline engine for revoco. |