Documentation
¶
Overview ¶
Package factory provides functionality for creating and managing plugins in the Lynx framework.
Index ¶
- func CreateTypedPlugin[T plugins.Plugin](factory *TypedFactory, name string) (T, error)
- func GetTypedPlugin[T plugins.Plugin](factory *TypedFactory, name string) (T, error)
- func RegisterTypedPlugin[T plugins.Plugin](factory *TypedFactory, name string, configPrefix string, creator func() T)
- type Creator
- type Factory
- type Registry
- type TypedFactory
- func (f *TypedFactory) CreatePlugin(name string) (plugins.Plugin, error)
- func (f *TypedFactory) GetConfigMapping() map[string][]string
- func (f *TypedFactory) GetPluginRegistry() map[string][]string
- func (f *TypedFactory) HasPlugin(name string) bool
- func (f *TypedFactory) RegisterPlugin(name string, configPrefix string, creator func() plugins.Plugin)
- func (f *TypedFactory) UnregisterPlugin(name string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTypedPlugin ¶
func CreateTypedPlugin[T plugins.Plugin](factory *TypedFactory, name string) (T, error)
CreateTypedPlugin creates a type-safe plugin instance
func GetTypedPlugin ¶
func GetTypedPlugin[T plugins.Plugin](factory *TypedFactory, name string) (T, error)
GetTypedPlugin gets a type-safe plugin instance
func RegisterTypedPlugin ¶
func RegisterTypedPlugin[T plugins.Plugin]( factory *TypedFactory, name string, configPrefix string, creator func() T, )
RegisterTypedPlugin registers a type-safe plugin
Types ¶
type Creator ¶
type Creator interface {
// CreatePlugin instantiates a new plugin instance by its name.
// Returns an error if the plugin cannot be created.
CreatePlugin(name string) (plugins.Plugin, error)
}
Creator defines the interface for creating plugin instances.
type Factory ¶
Factory defines the complete interface for plugin management, combining both creation and registry capabilities.
type Registry ¶
type Registry interface {
// RegisterPlugin adds a new plugin to the registry with its configuration prefix
// and creation function.
RegisterPlugin(name string, configPrefix string, creator func() plugins.Plugin)
// UnregisterPlugin removes a plugin from the registry.
UnregisterPlugin(name string)
// GetPluginRegistry returns the mapping of configuration prefixes to plugin names.
GetPluginRegistry() map[string][]string
// HasPlugin checks if a plugin is registered with the given name.
HasPlugin(name string) bool
}
Registry defines the interface for managing plugin registrations.
type TypedFactory ¶
type TypedFactory struct {
// contains filtered or unexported fields
}
TypedFactory type-safe plugin factory
func GlobalTypedFactory ¶
func GlobalTypedFactory() *TypedFactory
GlobalTypedFactory returns the global type-safe plugin factory.
func NewTypedFactory ¶
func NewTypedFactory() *TypedFactory
NewTypedFactory creates a type-safe plugin factory
func (*TypedFactory) CreatePlugin ¶
func (f *TypedFactory) CreatePlugin(name string) (plugins.Plugin, error)
CreatePlugin creates plugin instance (compatible with old interface)
func (*TypedFactory) GetConfigMapping ¶
func (f *TypedFactory) GetConfigMapping() map[string][]string
GetConfigMapping gets configuration mapping
func (*TypedFactory) GetPluginRegistry ¶
func (f *TypedFactory) GetPluginRegistry() map[string][]string
GetPluginRegistry returns the plugin registry (backward-compatible API).
func (*TypedFactory) HasPlugin ¶
func (f *TypedFactory) HasPlugin(name string) bool
HasPlugin checks if plugin exists
func (*TypedFactory) RegisterPlugin ¶
func (f *TypedFactory) RegisterPlugin(name string, configPrefix string, creator func() plugins.Plugin)
RegisterPlugin registers a plugin (backward-compatible signature for TypedFactory). Recommended usage in plugins: factory.GlobalTypedFactory().RegisterPlugin(...)
func (*TypedFactory) UnregisterPlugin ¶
func (f *TypedFactory) UnregisterPlugin(name string)
UnregisterPlugin unregisters a plugin.