Raxol.Plugins.Lifecycle (Raxol v0.4.0)

View Source

Handles the lifecycle management of Raxol plugins.

This includes loading, unloading, enabling, disabling, and managing dependencies and configuration persistence.

Summary

Functions

Disables a plugin by name.

Enables a plugin by name.

Loads a single plugin module and initializes it.

Loads multiple plugins in the correct dependency order.

Unloads a plugin by name.

Functions

disable_plugin(manager, name)

@spec disable_plugin(Raxol.Plugins.Manager.Core.t(), String.t()) ::
  {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, String.t()}

Disables a plugin by name.

Updates the configuration to disable the plugin, saves the configuration, and updates the plugin state in the manager. Returns {:ok, updated_manager} or {:error, reason}.

enable_plugin(manager, name)

@spec enable_plugin(Raxol.Plugins.Manager.Core.t(), String.t()) ::
  {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, String.t()}

Enables a plugin by name.

Checks dependencies, updates the configuration to enable the plugin, saves the configuration, and updates the plugin state in the manager. Returns {:ok, updated_manager} or {:error, reason}.

load_plugin(manager, module, config \\ %{})

@spec load_plugin(Raxol.Plugins.Manager.Core.t(), atom(), map()) ::
  {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, String.t()}

Loads a single plugin module and initializes it.

Handles configuration merging, API compatibility checks, dependency checks, and saving the updated configuration. Returns {:ok, updated_manager} or {:error, reason}.

load_plugins(manager, modules)

@spec load_plugins(Raxol.Plugins.Manager.Core.t(), [atom()]) ::
  {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, String.t()}

Loads multiple plugins in the correct dependency order.

Initializes all plugins first, resolves dependencies, then loads them one by one using load_plugin/3. Returns {:ok, updated_manager} or {:error, reason}.

unload_plugin(manager, name)

@spec unload_plugin(Raxol.Plugins.Manager.Core.t(), String.t()) ::
  {:ok, Raxol.Plugins.Manager.Core.t()} | {:error, String.t()}

Unloads a plugin by name.

Calls the plugin's cleanup/1 callback, updates the configuration to disable the plugin, saves the configuration, and removes the plugin from the manager state. Returns {:ok, updated_manager} or {:error, reason}.