Raxol.Core.Runtime.Plugins.DependencyManager.Resolver (Raxol v0.5.0)

View Source

Handles load order resolution for plugin dependencies using Tarjan's algorithm. Provides efficient cycle detection and topological sorting of dependencies.

Summary

Functions

Performs a topological sort of the dependency graph using Tarjan's algorithm. This algorithm efficiently detects cycles and produces a valid load order.

Functions

tarjan_sort(graph)

Performs a topological sort of the dependency graph using Tarjan's algorithm. This algorithm efficiently detects cycles and produces a valid load order.

Parameters

  • graph - The dependency graph

Returns

  • {:ok, order} - List of plugin IDs in the correct load order
  • {:error, cycle} - If a circular dependency is detected

Example

iex> Resolver.tarjan_sort(%{
  "plugin_a" => [{"plugin_b", ">= 1.0.0", %{optional: false}}],
  "plugin_b" => []
})
{:ok, ["plugin_b", "plugin_a"]}