Raxol.Core.Runtime.Plugins.DependencyManager (Raxol v0.5.0)
View SourceManages plugin dependencies, ensuring that plugins are loaded in the correct order and that their dependencies are met.
This module is the primary interface for dependency management, and it is composed of several smaller modules, each with a specific responsibility:
DependencyManager.Core
: Core dependency checking and load order resolutionDependencyManager.Version
: Version parsing and constraint checkingDependencyManager.Graph
: Dependency graph building and analysisDependencyManager.Resolver
: Load order resolution using Tarjan's algorithm
For more detailed documentation about the module's architecture and internals,
see docs/dependency_manager.md
.
Summary
Functions
Checks if a plugin's dependencies are met by the currently loaded plugins.
Resolves the load order for a list of plugins.
Checks if a version meets a version requirement.
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 if a plugin's dependencies are met by the currently loaded plugins.
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
Examples
iex> DependencyManager.check_dependencies("my_plugin", %{dependencies: [{"other_plugin", ">= 1.0.0"}]}, %{"other_plugin" => %{version: "1.1.0"}}, [])
:ok
iex> DependencyManager.check_dependencies("my_plugin", %{dependencies: [{"missing_plugin", ">= 1.0.0"}]}, %{}, [])
{:error, :missing_dependencies, ["missing_plugin"], ["my_plugin"]}
iex> DependencyManager.check_dependencies("my_plugin", %{dependencies: [{"other_plugin", ">= 2.0.0"}]}, %{"other_plugin" => %{version: "1.0.0"}}, [])
{:error, :version_mismatch, [{"other_plugin", "1.0.0", ">= 2.0.0"}], ["my_plugin"]}
Resolves the load order for a list of plugins.
Checks if a version meets a version requirement.