PhoenixAssets.Plugin.Resolver (PhoenixAssets v0.1.0)

View Source

Resolves a list of plugins into a deterministic execution order.

Given {module, opts} pairs in declaration order, the resolver reads each plugin's depends_on (hard) and after_plugin (soft) edges and produces a topological ordering via Kahn's algorithm. Ties (several plugins ready at once) break by declaration order, so the result is stable. A hard dependency that is absent fails with {:missing_dependency, plugin, dependency}; a cycle fails with {:cycle, modules}.

See also

Summary

Functions

Renders a resolver error as a human-readable string.

Resolves plugins into topological order.

Types

error()

@type error() ::
  {:duplicate, module()}
  | {:missing_dependency, module(), module()}
  | {:cycle, [module()]}

plugin()

@type plugin() :: {module(), keyword()}

Functions

format_error(arg)

@spec format_error(error()) :: String.t()

Renders a resolver error as a human-readable string.

resolve(plugins)

@spec resolve([plugin()]) :: {:ok, [plugin()]} | {:error, error()}

Resolves plugins into topological order.

Returns {:ok, ordered_plugins} preserving each plugin's opts, or {:error, reason}.