Registry for plugin management and lookup.
Maintains a catalog of available plugins and their components. Used by the runtime to resolve component types and capabilities.
Architecture
The registry is an ETS-backed catalog that maps:
- component type (string) → plugin module
- plugin module → plugin info
- capability → [component types]
- plugin module → status
- plugin module → runtime state
This enables fast lookup during rendering and capability negotiation.
Usage
# Register a plugin
MyApp.VideoPlugin.register()
# Look up a component's plugin
{:ok, plugin} = Dala.Plugin.Registry.lookup_component("video")
# Check capabilities
Dala.Plugin.Registry.supports_capability?(:gestures)
# Get all components with a capability
Dala.Plugin.Registry.components_with_capability(:gestures)
# Lifecycle management
Dala.Plugin.Registry.init_all()
Dala.Plugin.Registry.cleanup_all()
# Find plugins by capability or platform
Dala.Plugin.Registry.find_by_capability(:gestures)
Dala.Plugin.Registry.find_by_platform(:ios)
Summary
Functions
Returns a specification to start this module under a supervisor.
Cleans up all plugins in reverse dependency order.
Clears all registrations.
Gets all components that support a given capability.
Finds all plugins that provide a given capability.
Finds all plugins that support a given platform.
Gets the plugin info for a plugin module.
Gets the runtime state of a plugin.
Gets the current status of a plugin.
Checks if a component type is registered.
Initializes all registered plugins in dependency order.
Gets all registered capabilities.
Lists all registered component types.
Lists all registered plugins.
Looks up the plugin for a given component type.
Registers a plugin with the runtime.
Returns plugins in topological order based on their declared dependencies.
Sets the runtime state of a plugin.
Sets the status of a plugin.
Starts the registry.
Checks if any registered component supports a given capability.
Unregisters a plugin.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec cleanup_all() :: :ok | {:error, term()}
Cleans up all plugins in reverse dependency order.
Calls Dala.Plugin.Lifecycle.cleanup/1 for each plugin, starting with
plugins that have the most dependencies and proceeding in reverse
topological order.
Returns :ok if all plugins clean up successfully, or
{:error, {module, reason}} on the first failure.
@spec clear() :: :ok
Clears all registrations.
@spec components_with_capability(Dala.Plugin.capability()) :: [String.t()]
Gets all components that support a given capability.
@spec find_by_capability(atom()) :: [Dala.Plugin.t()]
Finds all plugins that provide a given capability.
@spec find_by_platform(Dala.Plugin.platform()) :: [Dala.Plugin.t()]
Finds all plugins that support a given platform.
@spec get_plugin(module()) :: {:ok, Dala.Plugin.t()} | {:error, :not_found}
Gets the plugin info for a plugin module.
Gets the runtime state of a plugin.
@spec get_status(module()) :: Dala.Plugin.status() | nil
Gets the current status of a plugin.
Checks if a component type is registered.
@spec init_all() :: :ok | {:error, term()}
Initializes all registered plugins in dependency order.
Calls Dala.Plugin.Lifecycle.init/2 for each plugin, starting with
plugins that have no dependencies and proceeding in topological order.
Returns :ok if all plugins initialize successfully, or
{:error, {module, reason}} on the first failure.
@spec list_capabilities() :: [Dala.Plugin.capability()]
Gets all registered capabilities.
@spec list_components() :: [String.t()]
Lists all registered component types.
@spec list_plugins() :: [Dala.Plugin.t()]
Lists all registered plugins.
@spec lookup_component(String.t()) :: {:ok, Dala.Plugin.t()} | {:error, :not_found}
Looks up the plugin for a given component type.
Returns {:ok, plugin} if found, {:error, :not_found} otherwise.
@spec register(Dala.Plugin.t() | module()) :: :ok
Registers a plugin with the runtime.
The plugin's __plugin_info__/0 function is called to retrieve
its schema information.
Returns plugins in topological order based on their declared dependencies.
Plugins with no dependencies come first. If a cycle is detected,
returns {:error, {:cycle, modules}}.
Sets the runtime state of a plugin.
@spec set_status(module(), Dala.Plugin.status()) :: :ok
Sets the status of a plugin.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the registry.
@spec supports_capability?(Dala.Plugin.capability()) :: boolean()
Checks if any registered component supports a given capability.
@spec unregister(module()) :: :ok
Unregisters a plugin.