{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package capability\n\n## Functions\n\n```go\nfunc DetectRequired(cfg *config.WorkflowConfig) []string\n```\nDetectRequired 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.\n\n```go\nfunc RegisterModuleTypeMapping(moduleType string, capabilities ...string)\n```\nRegisterModuleTypeMapping records that a module type requires certain capabilities.\n\n```go\nfunc RegisterTriggerTypeMapping(triggerType string, capabilities ...string)\n```\nRegisterTriggerTypeMapping records trigger type to capability mapping.\n\n```go\nfunc RegisterWorkflowTypeMapping(workflowType string, capabilities ...string)\n```\nRegisterWorkflowTypeMapping records workflow type to capability mapping.\n\n```go\nfunc ResetMappings()\n```\nResetMappings clears all registered type-to-capability mappings. Intended for testing.\n\n## Types\n\n```go\ntype Contract struct {\n\t// Name is the capability identifier (e.g., \"http-server\", \"message-broker\").\n\tName string\n\n\t// Description is a human-readable explanation of what this capability provides.\n\tDescription string\n\n\t// InterfaceType is the reflect.Type of the Go interface that providers must implement.\n\tInterfaceType reflect.Type\n\n\t// RequiredMethods lists the method signatures for documentation and validation.\n\tRequiredMethods []MethodSignature\n}\n```\nContract 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.\n\n```go\ntype MethodSignature struct {\n\t// Name is the method name.\n\tName string\n\n\t// Params lists the parameter type names (excluding the receiver).\n\tParams []string\n\n\t// Returns lists the return type names.\n\tReturns []string\n}\n```\nMethodSignature describes a single method on a capability interface.\n\n```go\ntype ProviderEntry struct {\n\t// PluginName is the name of the plugin providing this capability.\n\tPluginName string\n\n\t// Priority determines provider selection order; higher values win.\n\tPriority int\n\n\t// InterfaceImpl is the reflect.Type of the concrete type implementing the capability.\n\tInterfaceImpl reflect.Type\n}\n```\nProviderEntry represents a plugin that implements a capability.\n\n```go\ntype Registry struct {\n\t// contains filtered or unexported fields\n}\n```\nRegistry manages capability contracts and their providers. It is safe for concurrent use.\n\n```go\nfunc NewRegistry() *Registry\n```\nNewRegistry creates a new empty capability registry.\n\n```go\nfunc (r *Registry) ContractFor(capabilityName string) (*Contract, bool)\n```\nContractFor returns the contract for a capability name. Returns false if the capability is not registered.\n\n```go\nfunc (r *Registry) HasProvider(capabilityName string) bool\n```\nHasProvider returns true if at least one provider is registered for the capability.\n\n```go\nfunc (r *Registry) ListCapabilities() []string\n```\nListCapabilities returns a sorted list of all registered capability names.\n\n```go\nfunc (r *Registry) ListProviders(capabilityName string) []ProviderEntry\n```\nListProviders returns all providers registered for a capability. Returns nil if no providers are registered.\n\n```go\nfunc (r *Registry) RegisterContract(c Contract) error\n```\nRegisterContract adds a capability contract to the registry. Returns an error if a contract with the same name already exists but has a different InterfaceType.\n\n```go\nfunc (r *Registry) RegisterProvider(capabilityName, pluginName string, priority int, implType reflect.Type) error\n```\nRegisterProvider registers a plugin as a provider for a capability. Returns an error if the capability has not been registered.\n\n```go\nfunc (r *Registry) Resolve(capabilityName string) (*ProviderEntry, error)\n```\nResolve returns the highest-priority provider for a capability. Returns an error if no providers are registered for the capability.\n\n","path":"github.com/GoCodeAlone/workflow/capability","name":"capability","synopsis":"","isRedistributable":true}
