Voile.PluginManager (Voile v0.1.23)

Copy Markdown View Source

Manages the full lifecycle of plugins in Voile.

Uses an ETS table for the plugin registry so active?/1 and status/1 are concurrent reads with no GenServer bottleneck. State-changing operations (install, activate, etc.) go through GenServer calls.

Plugin States

:installed   on_install/0 ran, migrations done, not yet active
:active      on_activate/0 ran, hooks registered, fully running
:inactive    on_deactivate/0 ran, hooks removed, data intact
:error       install or activate failed
:uninstalled  on_uninstall/0 ran, data optionally removed

Usage

Voile.PluginManager.install("Elixir.VoileLockerLuggage")
Voile.PluginManager.activate("Elixir.VoileLockerLuggage")
Voile.PluginManager.deactivate("Elixir.VoileLockerLuggage")
Voile.PluginManager.uninstall("Elixir.VoileLockerLuggage", remove_data: true)

Summary

Functions

Activate an installed plugin (registers hooks).

Check if a plugin is currently active.

Returns a specification to start this module under a supervisor.

Deactivate a plugin (removes hooks, keeps data).

Returns plugin modules that are loaded in the VM but not yet installed.

Install a plugin for the first time (runs migrations).

List only active plugin modules.

List all known plugins and their states.

Get the current status of a plugin. Accepts either an atom or a module string.

Uninstall a plugin.

Update a plugin to a new version. Runs on_update/2 with old and new version strings.

Functions

activate(module_str)

Activate an installed plugin (registers hooks).

active?(module)

Check if a plugin is currently active.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

deactivate(module_str)

Deactivate a plugin (removes hooks, keeps data).

discover_available()

Returns plugin modules that are loaded in the VM but not yet installed.

Scans all started OTP applications, derives the likely root module name by camelising the app atom (e.g. :voile_locker_luggageVoileLockerLuggage), tries to load it, and keeps those that implement the Voile.Plugin contract. Filters out modules already recorded in the database.

install(module_str)

Install a plugin for the first time (runs migrations).

list_active()

List only active plugin modules.

list_all()

List all known plugins and their states.

start_link(opts \\ [])

status(module)

Get the current status of a plugin. Accepts either an atom or a module string.

uninstall(module_str, opts \\ [])

Uninstall a plugin.

Options:

  • remove_data: true — calls on_uninstall/0 which drops tables. Default is false (keeps data, just marks as uninstalled).

update(module_str)

Update a plugin to a new version. Runs on_update/2 with old and new version strings.