Documentation
¶
Overview ¶
Package plugin implements infrastructure adapters for the plugin system.
The plugin package provides concrete implementations for plugin discovery, loading, validation, registration, and lifecycle management. It enables AWF workflows to extend functionality through external RPC-based plugins (operations, filters, transformers) without modifying core code. The package handles manifest parsing, version compatibility checking, state persistence, and operation registry integration.
Architecture Role ¶
In the hexagonal architecture:
- Implements plugin loading and lifecycle management (infrastructure adapters)
- Provides OperationRegistry for runtime operation lookup and registration
- Integrates with domain/ports.CommandExecutor for plugin discovery
- Application layer orchestrates workflow execution via registered plugin operations
- Domain layer defines operation contracts without plugin coupling
All plugin components use atomic file operations and thread-safe registries to support concurrent plugin loading during workflow initialization. The manifest parser validates semver constraints and capability declarations before plugin activation.
Plugin Management ¶
## RPCPluginManager (rpc_manager.go)
Plugin lifecycle orchestration:
- Discover: Scan plugins directory for valid manifests
- Load: Initialize plugin RPC client and register operations
- Init: Call plugin initialization hook with configuration
- Shutdown: Gracefully stop a running plugin
- ShutdownAll: Cleanup all active plugins on process termination
- Get: Retrieve loaded plugin by name
- List: Enumerate active plugin names
## Loader (loader.go)
Plugin discovery and validation:
- DiscoverPlugins: Find plugin.awf manifests in plugins directory
- LoadPlugin: Parse manifest, validate constraints, prepare RPC client
- ValidatePlugin: Check manifest schema, version compatibility, capability declarations
Registry and Discovery ¶
## OperationRegistry (registry.go)
Runtime operation registration and lookup:
- RegisterOperation: Add plugin-provided operation (thread-safe)
- UnregisterOperation: Remove operation by name
- GetOperation: Retrieve operation implementation by name
- GetPluginOperations: List operations provided by a plugin
- UnregisterPluginOperations: Remove all operations from a plugin
- Count: Total registered operations
- Clear: Reset registry state
Manifest and Metadata ¶
## ManifestParser (manifest_parser.go)
Plugin metadata parsing:
- ParseManifest: Read plugin.awf YAML manifest
- Validates: name, version, awf_version (semver constraints), capabilities
- Supports metadata: author, description, license, homepage
Capabilities: operation, filter, transform (plugin feature declarations)
State Persistence ¶
## JSONPluginStateStore (state_store.go)
Plugin state persistence:
- Save: Write plugin state to JSON file (atomic via temp file + rename)
- Load: Read plugin state from JSON file
- SetEnabled: Enable/disable plugin by name
- IsEnabled: Check if plugin is enabled
- GetConfig: Retrieve plugin-specific configuration
- SetConfig: Update plugin-specific configuration
- GetState: Access full plugin state
- ListDisabled: Enumerate disabled plugins
Uses file locking to prevent concurrent modification during workflow execution.
Version parsing, constraint checking, and comparison logic lives in pkg/registry/version.go.
Index ¶
- Constants
- Variables
- func SourceDataFromPluginSource(source PluginSource) (map[string]any, error)
- type CompositeOperationProvider
- func (c *CompositeOperationProvider) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
- func (c *CompositeOperationProvider) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
- func (c *CompositeOperationProvider) ListOperations() []*pluginmodel.OperationSchema
- type EventBus
- type EventDeliverer
- type EventStreamSender
- type FileSystemLoader
- func (l *FileSystemLoader) DiscoverPlugins(ctx context.Context, pluginsDir string) ([]*pluginmodel.PluginInfo, error)
- func (l *FileSystemLoader) LoadPlugin(ctx context.Context, pluginDir string) (*pluginmodel.PluginInfo, error)
- func (l *FileSystemLoader) ValidatePlugin(info *pluginmodel.PluginInfo) error
- type JSONPluginStateStore
- func (s *JSONPluginStateStore) BasePath() string
- func (s *JSONPluginStateStore) GetChecksum(pluginName string) (hexHash string, checksumAt int64, exists bool)
- func (s *JSONPluginStateStore) GetConfig(name string) map[string]any
- func (s *JSONPluginStateStore) GetSourceData(name string) map[string]any
- func (s *JSONPluginStateStore) GetState(name string) *pluginmodel.PluginState
- func (s *JSONPluginStateStore) IsEnabled(name string) bool
- func (s *JSONPluginStateStore) ListDisabled() []string
- func (s *JSONPluginStateStore) Load(ctx context.Context) error
- func (s *JSONPluginStateStore) RemoveState(ctx context.Context, name string) error
- func (s *JSONPluginStateStore) Save(ctx context.Context) error
- func (s *JSONPluginStateStore) SetChecksum(pluginName, hexHash string) error
- func (s *JSONPluginStateStore) SetConfig(ctx context.Context, name string, config map[string]any) error
- func (s *JSONPluginStateStore) SetEnabled(ctx context.Context, name string, enabled bool) error
- func (s *JSONPluginStateStore) SetSourceData(ctx context.Context, name string, data map[string]any) error
- type LoaderError
- type ManifestParseError
- type ManifestParser
- type OperationRegistry
- func (r *OperationRegistry) Clear()
- func (r *OperationRegistry) Count() int
- func (r *OperationRegistry) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
- func (r *OperationRegistry) GetOperationSource(operationName string) (string, bool)
- func (r *OperationRegistry) GetPluginOperations(pluginName string) []*pluginmodel.OperationSchema
- func (r *OperationRegistry) Operations() []*pluginmodel.OperationSchema
- func (r *OperationRegistry) RegisterOperation(op *pluginmodel.OperationSchema) error
- func (r *OperationRegistry) UnregisterOperation(name string) error
- func (r *OperationRegistry) UnregisterPluginOperations(pluginName string) error
- type PluginInstaller
- type PluginSource
- type RPCManagerError
- type RPCPluginManager
- func (m *RPCPluginManager) Discover(ctx context.Context) ([]*pluginmodel.PluginInfo, error)
- func (m *RPCPluginManager) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
- func (m *RPCPluginManager) Get(name string) (*pluginmodel.PluginInfo, bool)
- func (m *RPCPluginManager) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
- func (m *RPCPluginManager) Init(ctx context.Context, name string, config map[string]any) error
- func (m *RPCPluginManager) List() []*pluginmodel.PluginInfo
- func (m *RPCPluginManager) ListOperations() []*pluginmodel.OperationSchema
- func (m *RPCPluginManager) Load(ctx context.Context, name string) error
- func (m *RPCPluginManager) SetEventBus(bus *EventBus)
- func (m *RPCPluginManager) SetHostVersion(v string)
- func (m *RPCPluginManager) SetPluginsDir(dir string)
- func (m *RPCPluginManager) SetPluginsDirs(dirs []string)
- func (m *RPCPluginManager) SetStateStore(store *JSONPluginStateStore)
- func (m *RPCPluginManager) SetStreamManager(sm *StreamManager)
- func (m *RPCPluginManager) SetZapLogger(zapLogger *zap.Logger)
- func (m *RPCPluginManager) Shutdown(ctx context.Context, name string) error
- func (m *RPCPluginManager) ShutdownAll(ctx context.Context) error
- func (m *RPCPluginManager) StepTypeProvider(logger ports.Logger) ports.StepTypeProvider
- func (m *RPCPluginManager) ValidatorProvider(timeout time.Duration) ports.WorkflowValidatorProvider
- type StreamManager
- func (m *StreamManager) Close()
- func (m *StreamManager) GetDeliverer(pluginName string, unaryFallback EventDeliverer) EventDeliverer
- func (m *StreamManager) HasStream(pluginName string) bool
- func (m *StreamManager) RegisterStream(pluginName string, stream EventStreamSender)
- func (m *StreamManager) UnregisterStream(pluginName string)
- type SystemResult
Constants ¶
const DefaultPluginsDir = "plugins"
Default plugins directory relative to config.
const ManifestFileName = "plugin.yaml"
ManifestFileName is the expected filename for plugin manifests.
Variables ¶
var ( ErrOperationAlreadyRegistered = errors.New("operation already registered") ErrOperationNotFound = errors.New("operation not found") ErrInvalidOperation = errors.New("invalid operation schema") )
Registry errors.
var ErrNoPluginsConfigured = errors.New("rpc_manager: no plugins configured")
ErrNoPluginsConfigured indicates no plugin loader or directory is configured.
Functions ¶
func SourceDataFromPluginSource ¶ added in v0.5.0
func SourceDataFromPluginSource(source PluginSource) (map[string]any, error)
SourceDataFromPluginSource serializes a PluginSource to the format expected by PluginState.SourceData.
Types ¶
type CompositeOperationProvider ¶
type CompositeOperationProvider struct {
// contains filtered or unexported fields
}
CompositeOperationProvider wraps multiple OperationProvider instances into a single provider, delegating GetOperation/ListOperations/Execute by operation name. Enables coexistence of multiple built-in providers (e.g., github and notify).
func NewCompositeOperationProvider ¶
func NewCompositeOperationProvider(providers ...ports.OperationProvider) *CompositeOperationProvider
NewCompositeOperationProvider creates a new composite operation provider that delegates to the given providers.
func (*CompositeOperationProvider) Execute ¶
func (c *CompositeOperationProvider) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
Execute runs a plugin operation by delegating to the appropriate provider.
func (*CompositeOperationProvider) GetOperation ¶
func (c *CompositeOperationProvider) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
GetOperation returns an operation by name from the first provider that has it.
func (*CompositeOperationProvider) ListOperations ¶
func (c *CompositeOperationProvider) ListOperations() []*pluginmodel.OperationSchema
ListOperations returns all available operations from all providers.
type EventBus ¶ added in v0.11.2
type EventBus struct {
// contains filtered or unexported fields
}
func NewEventBus ¶ added in v0.11.2
NewEventBus creates an EventBus with default buffer size.
func NewEventBusWithBufferSize ¶ added in v0.11.2
NewEventBusWithBufferSize creates an EventBus with a custom buffer size (for testing).
func (*EventBus) Publish ¶ added in v0.11.2
func (b *EventBus) Publish(ctx context.Context, event *pluginmodel.DomainEvent) error
func (*EventBus) Subscribe ¶ added in v0.11.2
func (b *EventBus) Subscribe(pluginName string, patterns []string, deliverer EventDeliverer)
func (*EventBus) Unsubscribe ¶ added in v0.11.2
type EventDeliverer ¶ added in v0.11.2
type EventDeliverer interface {
DeliverEvent(ctx context.Context, event *pluginmodel.DomainEvent) ([]*pluginmodel.DomainEvent, error)
}
EventDeliverer decouples EventBus from the gRPC adapter, enabling unit testing with mock deliverers.
type EventStreamSender ¶ added in v0.11.2
type EventStreamSender interface {
Send(msg *pluginv1.EventStreamMessage) error
}
EventStreamSender is the client-side streaming interface for sending events to a plugin.
type FileSystemLoader ¶
type FileSystemLoader struct {
// contains filtered or unexported fields
}
FileSystemLoader implements PluginLoader for filesystem-based plugin discovery.
func NewFileSystemLoader ¶
func NewFileSystemLoader(parser *ManifestParser) *FileSystemLoader
NewFileSystemLoader creates a new FileSystemLoader with the given manifest parser.
func (*FileSystemLoader) DiscoverPlugins ¶
func (l *FileSystemLoader) DiscoverPlugins(ctx context.Context, pluginsDir string) ([]*pluginmodel.PluginInfo, error)
DiscoverPlugins scans a directory for plugins and returns their info. Each subdirectory containing a plugin.yaml is considered a plugin.
func (*FileSystemLoader) LoadPlugin ¶
func (l *FileSystemLoader) LoadPlugin(ctx context.Context, pluginDir string) (*pluginmodel.PluginInfo, error)
LoadPlugin loads a single plugin from a directory path. Reads the plugin.yaml manifest and creates PluginInfo with status=StatusLoaded.
func (*FileSystemLoader) ValidatePlugin ¶
func (l *FileSystemLoader) ValidatePlugin(info *pluginmodel.PluginInfo) error
ValidatePlugin checks if a discovered plugin is valid and compatible. Validates manifest fields, capabilities, and AWF version constraint.
type JSONPluginStateStore ¶
type JSONPluginStateStore struct {
// contains filtered or unexported fields
}
JSONPluginStateStore persists plugin states to a JSON file. Implements ports.PluginStateStore interface.
func NewJSONPluginStateStore ¶
func NewJSONPluginStateStore(basePath string) *JSONPluginStateStore
NewJSONPluginStateStore creates a new JSONPluginStateStore.
func (*JSONPluginStateStore) BasePath ¶
func (s *JSONPluginStateStore) BasePath() string
BasePath returns the storage directory path.
func (*JSONPluginStateStore) GetChecksum ¶ added in v0.11.2
func (s *JSONPluginStateStore) GetChecksum(pluginName string) (hexHash string, checksumAt int64, exists bool)
GetChecksum returns the stored checksum and its timestamp for a plugin. Returns ("", 0, false) if the plugin is unknown or has no checksum stored.
func (*JSONPluginStateStore) GetConfig ¶
func (s *JSONPluginStateStore) GetConfig(name string) map[string]any
GetConfig returns the stored configuration for a plugin. Returns nil if plugin has no stored configuration.
func (*JSONPluginStateStore) GetSourceData ¶ added in v0.5.0
func (s *JSONPluginStateStore) GetSourceData(name string) map[string]any
GetSourceData returns the stored source metadata for a plugin. Returns nil if plugin has no stored source data.
func (*JSONPluginStateStore) GetState ¶
func (s *JSONPluginStateStore) GetState(name string) *pluginmodel.PluginState
GetState returns the full state for a plugin, or nil if not found.
func (*JSONPluginStateStore) IsEnabled ¶
func (s *JSONPluginStateStore) IsEnabled(name string) bool
IsEnabled returns whether a plugin is enabled. Returns true for unknown plugins (enabled by default).
func (*JSONPluginStateStore) ListDisabled ¶
func (s *JSONPluginStateStore) ListDisabled() []string
ListDisabled returns names of all explicitly disabled plugins.
func (*JSONPluginStateStore) Load ¶
func (s *JSONPluginStateStore) Load(ctx context.Context) error
Load reads plugin states from storage.
func (*JSONPluginStateStore) RemoveState ¶ added in v0.5.0
func (s *JSONPluginStateStore) RemoveState(ctx context.Context, name string) error
RemoveState removes all state entries for a plugin name.
func (*JSONPluginStateStore) Save ¶
func (s *JSONPluginStateStore) Save(ctx context.Context) error
Save persists all plugin states to storage with atomic write.
func (*JSONPluginStateStore) SetChecksum ¶ added in v0.11.2
func (s *JSONPluginStateStore) SetChecksum(pluginName, hexHash string) error
SetChecksum stores the hex-encoded SHA-256 hash and current Unix timestamp for a plugin. Returns an error if the plugin is not yet registered in the state store.
func (*JSONPluginStateStore) SetConfig ¶
func (s *JSONPluginStateStore) SetConfig(ctx context.Context, name string, config map[string]any) error
SetConfig stores configuration for a plugin.
func (*JSONPluginStateStore) SetEnabled ¶
SetEnabled enables or disables a plugin by name.
func (*JSONPluginStateStore) SetSourceData ¶ added in v0.5.0
func (s *JSONPluginStateStore) SetSourceData(ctx context.Context, name string, data map[string]any) error
SetSourceData stores source metadata for a plugin.
type LoaderError ¶
type LoaderError struct {
Path string // plugin directory path
Op string // operation (discover, load, validate)
Message string // error message
Cause error // underlying error
}
LoaderError represents an error during plugin loading operations.
func NewLoaderError ¶
func NewLoaderError(op, path, message string) *LoaderError
NewLoaderError creates a new LoaderError.
func WrapLoaderError ¶
func WrapLoaderError(op, path string, cause error) *LoaderError
WrapLoaderError wraps an existing error as a LoaderError.
func (*LoaderError) Error ¶
func (e *LoaderError) Error() string
Error implements the error interface.
func (*LoaderError) Unwrap ¶
func (e *LoaderError) Unwrap() error
Unwrap returns the underlying error.
type ManifestParseError ¶
type ManifestParseError struct {
File string // file path
Field string // field path (e.g., "config.webhook_url")
Message string // error message
Cause error // underlying error
}
ManifestParseError represents an error during plugin manifest parsing.
func NewManifestParseError ¶
func NewManifestParseError(file, field, message string) *ManifestParseError
NewManifestParseError creates a new ManifestParseError with field and message.
func WrapManifestParseError ¶
func WrapManifestParseError(file string, cause error) *ManifestParseError
WrapManifestParseError wraps an existing error as a ManifestParseError.
func (*ManifestParseError) Error ¶
func (e *ManifestParseError) Error() string
Error implements the error interface.
func (*ManifestParseError) Unwrap ¶
func (e *ManifestParseError) Unwrap() error
Unwrap returns the underlying error.
type ManifestParser ¶
type ManifestParser struct{}
ManifestParser parses plugin manifests from YAML files.
func NewManifestParser ¶
func NewManifestParser() *ManifestParser
NewManifestParser creates a new ManifestParser.
func (*ManifestParser) Parse ¶
func (p *ManifestParser) Parse(r io.Reader) (*pluginmodel.Manifest, error)
Parse reads and parses a plugin manifest from an io.Reader.
func (*ManifestParser) ParseFile ¶
func (p *ManifestParser) ParseFile(path string) (*pluginmodel.Manifest, error)
ParseFile reads and parses a plugin manifest from a file path.
type OperationRegistry ¶
type OperationRegistry struct {
// contains filtered or unexported fields
}
OperationRegistry manages registration of plugin-provided operations. Thread-safe for concurrent access.
func NewOperationRegistry ¶
func NewOperationRegistry() *OperationRegistry
NewOperationRegistry creates a new empty operation registry.
func (*OperationRegistry) Clear ¶
func (r *OperationRegistry) Clear()
Clear removes all registered operations. Useful for testing.
func (*OperationRegistry) Count ¶
func (r *OperationRegistry) Count() int
Count returns the total number of registered operations.
func (*OperationRegistry) GetOperation ¶
func (r *OperationRegistry) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
GetOperation returns an operation by name. Returns nil and false if the operation is not found.
func (*OperationRegistry) GetOperationSource ¶
func (r *OperationRegistry) GetOperationSource(operationName string) (string, bool)
GetOperationSource returns the plugin name that registered an operation. Returns empty string and false if the operation is not found.
func (*OperationRegistry) GetPluginOperations ¶
func (r *OperationRegistry) GetPluginOperations(pluginName string) []*pluginmodel.OperationSchema
GetPluginOperations returns all operations registered by a specific plugin.
func (*OperationRegistry) Operations ¶
func (r *OperationRegistry) Operations() []*pluginmodel.OperationSchema
Operations returns all registered operations as a slice. Returns an empty slice if no operations are registered.
func (*OperationRegistry) RegisterOperation ¶
func (r *OperationRegistry) RegisterOperation(op *pluginmodel.OperationSchema) error
RegisterOperation adds a plugin operation to the registry. Returns ErrOperationAlreadyRegistered if an operation with the same name exists. Returns ErrInvalidOperation if the operation schema is nil or has no name.
func (*OperationRegistry) UnregisterOperation ¶
func (r *OperationRegistry) UnregisterOperation(name string) error
UnregisterOperation removes a plugin operation from the registry. Returns ErrOperationNotFound if the operation is not registered.
func (*OperationRegistry) UnregisterPluginOperations ¶
func (r *OperationRegistry) UnregisterPluginOperations(pluginName string) error
UnregisterPluginOperations removes all operations provided by a specific plugin. Useful when unloading or disabling a plugin.
type PluginInstaller ¶ added in v0.5.0
type PluginInstaller struct {
// contains filtered or unexported fields
}
PluginInstaller handles downloading, verifying, extracting, and atomically installing plugins from GitHub releases.
func NewPluginInstaller ¶ added in v0.5.0
func NewPluginInstaller(optionalClient ...httpx.HTTPDoer) *PluginInstaller
NewPluginInstaller creates a new PluginInstaller with optional client injection. If client is nil, uses a default *http.Client.
func (*PluginInstaller) AtomicInstall ¶ added in v0.5.0
func (pi *PluginInstaller) AtomicInstall(tempDir, targetDir string) error
AtomicInstall performs an atomic installation by moving a temp directory to the final location. tempDir: temporary directory with extracted plugin files targetDir: final plugin installation directory Returns error if installation fails; targetDir is rolled back on failure.
func (*PluginInstaller) Install ¶ added in v0.5.0
func (pi *PluginInstaller) Install(ctx context.Context, url, checksum, targetDir string, force bool) error
Install downloads, verifies, extracts, and installs a plugin. Performs atomic installation with rollback on failure. Validates manifest exists after extraction. Rejects installation if plugin already exists (unless force=true).
ctx: context for cancellation url: download URL of plugin archive checksum: expected SHA-256 checksum (hex string) targetDir: directory where plugin will be installed force: if true, overwrites existing plugin directory
Returns error if: - Plugin already exists and force=false - Download fails - Checksum verification fails - Extraction fails - Manifest validation fails - Installation fails
func (*PluginInstaller) ValidateManifest ¶ added in v0.5.0
func (pi *PluginInstaller) ValidateManifest(dir string) error
ValidateManifest checks that a plugin directory contains a valid manifest file. dir: plugin directory to validate Returns error if manifest is missing or invalid.
type PluginSource ¶ added in v0.5.0
type PluginSource struct {
Repository string `json:"repository"` // e.g., "owner/repo"
Version string `json:"version"` // e.g., "1.2.3"
InstalledAt time.Time `json:"installed_at"`
UpdatedAt time.Time `json:"updated_at"`
}
PluginSource represents the origin and installation metadata of an external plugin. Serialized to PluginState.SourceData for persistence.
func PluginSourceFromSourceData ¶ added in v0.5.0
func PluginSourceFromSourceData(sourceData map[string]any) (PluginSource, error)
PluginSourceFromSourceData deserializes SourceData from PluginState into a PluginSource.
type RPCManagerError ¶
type RPCManagerError struct {
Op string // operation (load, init, shutdown)
Plugin string // plugin name
Message string // error message
Cause error // underlying error
}
RPCManagerError represents an error during plugin lifecycle operations.
func NewRPCManagerError ¶
func NewRPCManagerError(op, pluginName, message string) *RPCManagerError
NewRPCManagerError creates a new RPCManagerError.
func WrapRPCManagerError ¶
func WrapRPCManagerError(op, pluginName string, cause error) *RPCManagerError
WrapRPCManagerError wraps an existing error as an RPCManagerError.
func (*RPCManagerError) Error ¶
func (e *RPCManagerError) Error() string
Error implements the error interface.
func (*RPCManagerError) Unwrap ¶
func (e *RPCManagerError) Unwrap() error
Unwrap returns the underlying error.
type RPCPluginManager ¶
type RPCPluginManager struct {
// contains filtered or unexported fields
}
RPCPluginManager implements PluginManager using HashiCorp go-plugin for RPC. It manages plugin lifecycle: discovery, loading, initialization, and shutdown.
func NewRPCPluginManager ¶
func NewRPCPluginManager(loader *FileSystemLoader) *RPCPluginManager
NewRPCPluginManager creates a new RPCPluginManager.
func (*RPCPluginManager) Discover ¶
func (m *RPCPluginManager) Discover(ctx context.Context) ([]*pluginmodel.PluginInfo, error)
Discover finds plugins in the plugins directory. Returns ErrNoPluginsConfigured if no loader or plugins directory is configured.
func (*RPCPluginManager) Execute ¶
func (m *RPCPluginManager) Execute(ctx context.Context, name string, inputs map[string]any) (*pluginmodel.OperationResult, error)
Execute delegates an operation call to the correct connected plugin via gRPC. Name format is "pluginName.operationName" (consistent with built-in providers). If unprefixed, iterates all connections as fallback.
func (*RPCPluginManager) Get ¶
func (m *RPCPluginManager) Get(name string) (*pluginmodel.PluginInfo, bool)
Get returns plugin info by name. Returns (nil, false) if plugin not found.
func (*RPCPluginManager) GetOperation ¶
func (m *RPCPluginManager) GetOperation(name string) (*pluginmodel.OperationSchema, bool)
GetOperation returns an operation schema by name, searching all connected plugins. Name format is "pluginName.operationName" (consistent with built-in providers). Uses an internal 5s timeout per call because the port interface does not accept ctx.
func (*RPCPluginManager) List ¶
func (m *RPCPluginManager) List() []*pluginmodel.PluginInfo
List returns all known plugins.
func (*RPCPluginManager) ListOperations ¶
func (m *RPCPluginManager) ListOperations() []*pluginmodel.OperationSchema
ListOperations returns all operation schemas from all connected plugins. Calls gRPC ListOperations on each connection; skips plugins that fail. Uses an internal 5s timeout per call because the port interface does not accept ctx.
func (*RPCPluginManager) Load ¶
func (m *RPCPluginManager) Load(ctx context.Context, name string) error
Load loads a plugin by name. The plugin must have been discovered first, or a pluginsDir must be configured.
func (*RPCPluginManager) SetEventBus ¶ added in v0.11.2
func (m *RPCPluginManager) SetEventBus(bus *EventBus)
SetEventBus injects an EventBus for event subscription wiring after plugin Init. Must be called before any Init() calls to enable event routing.
func (*RPCPluginManager) SetHostVersion ¶ added in v0.11.2
func (m *RPCPluginManager) SetHostVersion(v string)
SetHostVersion overrides the default host version used for plugin compatibility checks.
func (*RPCPluginManager) SetPluginsDir ¶
func (m *RPCPluginManager) SetPluginsDir(dir string)
SetPluginsDir sets the directory to discover plugins from. SetPluginsDir configures a single plugin directory (replaces any previous config).
func (*RPCPluginManager) SetPluginsDirs ¶ added in v0.5.0
func (m *RPCPluginManager) SetPluginsDirs(dirs []string)
SetPluginsDirs configures multiple plugin directories to scan. Plugins are discovered from all directories; first-found wins on name conflicts.
func (*RPCPluginManager) SetStateStore ¶ added in v0.11.2
func (m *RPCPluginManager) SetStateStore(store *JSONPluginStateStore)
SetStateStore injects a JSONPluginStateStore for launch-time checksum verification. Must be called before any Init() calls to enable checksum enforcement.
func (*RPCPluginManager) SetStreamManager ¶ added in v0.11.2
func (m *RPCPluginManager) SetStreamManager(sm *StreamManager)
SetStreamManager injects a StreamManager for stream-based event delivery. Must be called before any Init() calls to enable stream routing.
func (*RPCPluginManager) SetZapLogger ¶ added in v0.11.2
func (m *RPCPluginManager) SetZapLogger(zapLogger *zap.Logger)
SetZapLogger injects a zap.Logger used for the hclog adapter and stdout/stderr capture. When not set, startPluginProcess falls back to zap.NewNop().
func (*RPCPluginManager) Shutdown ¶
func (m *RPCPluginManager) Shutdown(ctx context.Context, name string) error
Shutdown stops a running plugin gracefully. Full implementation: gRPC Shutdown call, client.Kill(), connection cleanup from m.connections.
func (*RPCPluginManager) ShutdownAll ¶
func (m *RPCPluginManager) ShutdownAll(ctx context.Context) error
ShutdownAll stops all running plugins with a 5s per-plugin deadline. Errors are accumulated via errors.Join() so all plugins are attempted even on partial failure.
func (*RPCPluginManager) StepTypeProvider ¶ added in v0.5.0
func (m *RPCPluginManager) StepTypeProvider(logger ports.Logger) ports.StepTypeProvider
StepTypeProvider returns a StepTypeProvider wrapping all step-type-capable plugins. Returns nil when no plugins have declared the step_types capability.
func (*RPCPluginManager) ValidatorProvider ¶ added in v0.5.0
func (m *RPCPluginManager) ValidatorProvider(timeout time.Duration) ports.WorkflowValidatorProvider
ValidatorProvider returns a WorkflowValidatorProvider wrapping all validator-capable plugins. Returns nil when no plugins have declared the validators capability.
type StreamManager ¶ added in v0.11.2
type StreamManager struct {
// contains filtered or unexported fields
}
StreamManager tracks per-plugin client-side gRPC streams and provides EventDeliverer instances.
func NewStreamManager ¶ added in v0.11.2
func NewStreamManager(logger ports.Logger) *StreamManager
NewStreamManager creates a StreamManager with the default send timeout.
func (*StreamManager) Close ¶ added in v0.11.2
func (m *StreamManager) Close()
Close removes all registered streams.
func (*StreamManager) GetDeliverer ¶ added in v0.11.2
func (m *StreamManager) GetDeliverer(pluginName string, unaryFallback EventDeliverer) EventDeliverer
GetDeliverer returns a streamDeliverer when a stream is registered, otherwise unaryFallback.
func (*StreamManager) HasStream ¶ added in v0.11.2
func (m *StreamManager) HasStream(pluginName string) bool
HasStream reports whether a stream is registered for pluginName.
func (*StreamManager) RegisterStream ¶ added in v0.11.2
func (m *StreamManager) RegisterStream(pluginName string, stream EventStreamSender)
RegisterStream stores a stream connection for pluginName.
func (*StreamManager) UnregisterStream ¶ added in v0.11.2
func (m *StreamManager) UnregisterStream(pluginName string)
UnregisterStream removes the stream for pluginName.
type SystemResult ¶ added in v0.11.2
type SystemResult struct {
Service *application.PluginService
Manager ports.OperationProvider
RPCManager *RPCPluginManager
StateStore *JSONPluginStateStore
EventBus *EventBus
Cleanup func()
}
SystemResult contains the initialized plugin system components.
func InitSystem ¶ added in v0.11.2
func InitSystem(ctx context.Context, pluginDirs []string, stateStorePath, hostVersion string, logger ports.Logger) (*SystemResult, error)
InitSystem initializes the plugin infrastructure from the given directories. pluginDirs may be nil or empty — returns a stub service with graceful degradation. stateStorePath: directory for persisting plugin enable/disable state. hostVersion: AWF CLI version for plugin compatibility checks (e.g. "0.8.0"). logger may be nil; log calls are skipped when it is nil.