Raxol.Core.Runtime.Plugins.Loader (Raxol v0.2.0)

View Source

Placeholder for the plugin loader. Handles loading plugin code and dependencies.

Summary

Functions

Discovers potential plugin modules in a given directory.

Extracts metadata for a given plugin module.

Ensures the code for a given plugin module is loaded. Returns :ok or {:error, :module_not_found}.

Loads a plugin module based on its ID.

Sorts plugins based on dependencies (Placeholder).

Functions

discover_plugins(directory)

Discovers potential plugin modules in a given directory.

Scans for .ex files and attempts to derive module names. Returns a list of {potential_module_atom, file_path} tuples.

extract_metadata(plugin_module)

Extracts metadata for a given plugin module.

Checks if the plugin implements Raxol.Core.Runtime.Plugins.PluginMetadataProvider. If so, it calls get_metadata/0 on the module. Otherwise, it returns a default metadata map derived from the module name.

load_code(plugin_module)

Ensures the code for a given plugin module is loaded. Returns :ok or {:error, :module_not_found}.

load_plugin(plugin_id, config \\ %{})

@spec load_plugin(atom(), map()) :: {:ok, module(), map(), map()} | {:error, term()}

Loads a plugin module based on its ID.

Assumes the plugin ID corresponds to an existing module atom. Returns the module atom, placeholder metadata, and config.

module_to_default_id(plugin_module)

sort_plugins(plugin_list)

Sorts plugins based on dependencies (Placeholder).

Currently returns the input list unsorted. Requires metadata extraction to be implemented first for actual sorting. Returns {:ok, sorted_plugin_ids} or {:error, reason}.