Raxol.Core.Runtime.Plugins.DependencyManager.Core (Raxol v0.5.0)
View SourceCore module for managing plugin dependencies and dependency resolution. Provides the main public API for dependency checking and load order resolution.
Summary
Functions
Checks for circular dependencies in the plugin graph.
Checks if a plugin's dependencies are satisfied.
Resolves dependencies between plugins.
Resolves the load order for a set of plugins based on their dependencies. Uses Tarjan's algorithm for efficient cycle detection and component identification.
Validates a list of dependencies.
Types
@type dependency() :: {String.t(), version_constraint()} | String.t()
@type dependency_chain() :: [String.t()]
@type dependency_error() :: {:error, :missing_dependencies, [String.t()], dependency_chain()} | {:error, :version_mismatch, [{String.t(), String.t(), version_constraint()}], dependency_chain()} | {:error, :circular_dependency, [String.t()], dependency_chain()}
@type version_constraint() :: String.t()
Functions
Checks for circular dependencies in the plugin graph.
Parameters
plugin_id
- The ID of the plugin to checkdependencies
- List of dependencies to checkloaded_plugins
- Map of currently loaded plugins
Returns
:ok
- If no circular dependencies are found{:error, :circular_dependency, cycle, chain}
- If a circular dependency is detected
Checks if a plugin's dependencies are satisfied.
Parameters
plugin_id
- The ID of the plugin to checkplugin_metadata
- The plugin's metadata containing its dependenciesloaded_plugins
- Map of currently loaded pluginsdependency_chain
- List of plugin IDs in the current dependency chain (for error reporting)
Returns
:ok
- If all dependencies are satisfied{:error, :missing_dependencies, missing, chain}
- If any dependencies are missing{:error, :version_mismatch, mismatches, chain}
- If any dependencies have incompatible versions{:error, :circular_dependency, cycle, chain}
- If a circular dependency is detected
Resolves dependencies between plugins.
Parameters
plugin_metadata
- The plugin's metadata containing its dependenciesloaded_plugins
- Map of currently loaded plugins
Returns
{:ok, resolved_deps}
- List of resolved dependencies{:error, reason}
- If dependency resolution fails
Resolves the load order for a set of plugins based on their dependencies. Uses Tarjan's algorithm for efficient cycle detection and component identification.
Parameters
plugins
- Map of plugin metadata, keyed by plugin ID
Returns
{:ok, load_order}
- List of plugin IDs in the correct load order{:error, :circular_dependency, cycle, chain}
- If a circular dependency is detected
Validates a list of dependencies.
Parameters
dependencies
- List of dependencies to validate
Returns
:ok
- If all dependencies are valid{:error, reason}
- If any dependencies are invalid