Dala.Plugin.Registry (dala v0.0.11)

Copy Markdown View Source

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]

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)

Summary

Functions

Returns a specification to start this module under a supervisor.

Clears all registrations.

Gets all components that support a given capability.

Gets the plugin info for a plugin module.

Checks if a component type is registered.

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.

Starts the registry.

Checks if any registered component supports a given capability.

Unregisters a plugin.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

@spec clear() :: :ok

Clears all registrations.

components_with_capability(capability)

@spec components_with_capability(Plugin.capability()) :: [String.t()]

Gets all components that support a given capability.

get_plugin(module)

@spec get_plugin(module()) :: {:ok, Dala.Plugin.t()} | {:error, :not_found}

Gets the plugin info for a plugin module.

has_component?(component_type)

@spec has_component?(String.t()) :: boolean()

Checks if a component type is registered.

list_capabilities()

@spec list_capabilities() :: [Plugin.capability()]

Gets all registered capabilities.

list_components()

@spec list_components() :: [String.t()]

Lists all registered component types.

list_plugins()

@spec list_plugins() :: [Dala.Plugin.t()]

Lists all registered plugins.

lookup_component(component_type)

@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.

register(plugin)

@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.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the registry.

supports_capability?(capability)

@spec supports_capability?(Plugin.capability()) :: boolean()

Checks if any registered component supports a given capability.

unregister(module)

@spec unregister(module()) :: :ok

Unregisters a plugin.