nova_plugin_manager (nova v0.14.3)
View SourceMain manager for handling plugins
Summary
Functions
Adds a plugin to the manager. The plugin module must implement the plugin_info/0 function returning #{title := Title, version := Version}. Optionally it can implement init/0 returning the initial state for the plugin, and stop/0 for cleaning up when the manager terminates.
Gets the state of a plugin. The plugin can be specified either as a module or as a callback function. The callback function is used to extract the module name in order to retrieve the state.
Sets the state of a plugin. The plugin can be specified either as a module or as a callback function. The callback function is used to extract the module name in order to set the state.
Starts the server
Functions
-spec add_plugin({Class :: atom(), Module :: atom(), Opts :: map()} | (Module :: atom() | (Callback :: function()))) -> ok | {error, Reason :: term()}.
Adds a plugin to the manager. The plugin module must implement the plugin_info/0 function returning #{title := Title, version := Version}. Optionally it can implement init/0 returning the initial state for the plugin, and stop/0 for cleaning up when the manager terminates.
-spec get_state(Module :: atom() | (Callback :: function())) -> {ok, State :: nova:state()} | {error, not_found}.
Gets the state of a plugin. The plugin can be specified either as a module or as a callback function. The callback function is used to extract the module name in order to retrieve the state.
-spec set_state(Module :: atom() | (Callback :: function()), NewState :: term()) -> ok | {error, not_found}.
Sets the state of a plugin. The plugin can be specified either as a module or as a callback function. The callback function is used to extract the module name in order to set the state.
-spec start_link() -> {ok, Pid :: pid()} | {error, Error :: {already_started, pid()}} | {error, Error :: term()} | ignore.
Starts the server