capability

package
v0.0.0-...-54d7c77 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectRequired

func DetectRequired(cfg *config.WorkflowConfig) []string

DetectRequired scans a WorkflowConfig and returns the set of capabilities needed. It inspects module types, trigger types, and workflow types and returns a deduplicated, sorted list of required capabilities.

func RegisterModuleTypeMapping

func RegisterModuleTypeMapping(moduleType string, capabilities ...string)

RegisterModuleTypeMapping records that a module type requires certain capabilities.

func RegisterTriggerTypeMapping

func RegisterTriggerTypeMapping(triggerType string, capabilities ...string)

RegisterTriggerTypeMapping records trigger type to capability mapping.

func RegisterWorkflowTypeMapping

func RegisterWorkflowTypeMapping(workflowType string, capabilities ...string)

RegisterWorkflowTypeMapping records workflow type to capability mapping.

func ResetMappings

func ResetMappings()

ResetMappings clears all registered type-to-capability mappings. Intended for testing.

Types

type Contract

type Contract struct {
	// Name is the capability identifier (e.g., "http-server", "message-broker").
	Name string

	// Description is a human-readable explanation of what this capability provides.
	Description string

	// InterfaceType is the reflect.Type of the Go interface that providers must implement.
	InterfaceType reflect.Type

	// RequiredMethods lists the method signatures for documentation and validation.
	RequiredMethods []MethodSignature
}

Contract defines a capability category that plugins can provide. A contract specifies the Go interface that providers must implement and documents the required method signatures for validation.

type MethodSignature

type MethodSignature struct {
	// Name is the method name.
	Name string

	// Params lists the parameter type names (excluding the receiver).
	Params []string

	// Returns lists the return type names.
	Returns []string
}

MethodSignature describes a single method on a capability interface.

type ProviderEntry

type ProviderEntry struct {
	// PluginName is the name of the plugin providing this capability.
	PluginName string

	// Priority determines provider selection order; higher values win.
	Priority int

	// InterfaceImpl is the reflect.Type of the concrete type implementing the capability.
	InterfaceImpl reflect.Type
}

ProviderEntry represents a plugin that implements a capability.

type Registry

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

Registry manages capability contracts and their providers. It is safe for concurrent use.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new empty capability registry.

func (*Registry) ContractFor

func (r *Registry) ContractFor(capabilityName string) (*Contract, bool)

ContractFor returns the contract for a capability name. Returns false if the capability is not registered.

func (*Registry) HasProvider

func (r *Registry) HasProvider(capabilityName string) bool

HasProvider returns true if at least one provider is registered for the capability.

func (*Registry) ListCapabilities

func (r *Registry) ListCapabilities() []string

ListCapabilities returns a sorted list of all registered capability names.

func (*Registry) ListProviders

func (r *Registry) ListProviders(capabilityName string) []ProviderEntry

ListProviders returns all providers registered for a capability. Returns nil if no providers are registered.

func (*Registry) RegisterContract

func (r *Registry) RegisterContract(c Contract) error

RegisterContract adds a capability contract to the registry. Returns an error if a contract with the same name already exists but has a different InterfaceType.

func (*Registry) RegisterProvider

func (r *Registry) RegisterProvider(capabilityName, pluginName string, priority int, implType reflect.Type) error

RegisterProvider registers a plugin as a provider for a capability. Returns an error if the capability has not been registered.

func (*Registry) Resolve

func (r *Registry) Resolve(capabilityName string) (*ProviderEntry, error)

Resolve returns the highest-priority provider for a capability. Returns an error if no providers are registered for the capability.

Jump to

Keyboard shortcuts

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