Module z_module_manager

Module supervisor.

Copyright 2009-2011 Marc Worrell Date: 2009-06-03

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

Module supervisor. Uses a z_supervisor. Starts/restarts module processes.

Function Index

activate/2Activate a module.
active/1Return the list of active modules.
active/2Return whether a specific module is active.
active_dir/1Return the list of all active modules and their directories.
add_observers/3Add the observers for a module, called after module has been activated.
all/1Return the list of all modules in the database.
code_change/3Convert process state when code is changed.
deactivate/2Deactivate a module.
dependencies/1Return a module's dependencies as a tuple usable for z_toposort:sort/1.
dependency_sort/1Sort all modules on their dependencies (with sub sort the module's priority).
get_modules/1Return the list of all modules running.
get_modules_status/1Return the status of all running modules.
get_provided/1Return the list of all provided functionalities in running modules.
handle_call/3Return a list of all enabled modules managed by the z_supervisor.
handle_cast/2Sync enabled modules with loaded modules.
handle_info/2Handling all non call/cast messages.
init/1Initiates the server.
module_exists/1Check if the code of a module exists.
prio/1Return the priority of a module.
prio_sort/1Sort the results of a scan on module priority first, module name next.
reinstall/2Reinstall the given module's schema, calling Module:manage_schema(install, Context); if that function exists.
remove_observers/3Remove the observers for a module, called before module is deactivated.
restart/2Shortcut, restart a module by deactivating and reactivating the module.
scan/1Scan for a list of modules present in the site's module directories.
start_link/1Starts the module manager.
startable/2
terminate/2This function is called by a gen_server when it is about to terminate.
title/1Get the title of a module.
upgrade/1Reload the list of all modules, add processes if necessary.
whereis/2Return the pid of a running module.

Function Details

activate/2

activate(Module, Context::#context{}) -> void()

Activate a module. The module is marked as active and started as a child of the module z_supervisor. The module manager can be checked later to see if the module started or not.

active/1

active(Context::#context{}) -> [atom()]

Return the list of active modules.

active/2

active(Module::atom(), Context::#context{}) -> boolean()

Return whether a specific module is active.

active_dir/1

active_dir(Context::#context{}) -> [{atom, Dir}]

Return the list of all active modules and their directories

add_observers/3

add_observers(Module, Pid, Context) -> any()

Add the observers for a module, called after module has been activated

all/1

all(Context::#context{}) -> [atom()]

Return the list of all modules in the database.

code_change/3

code_change(OldVsn, State, Extra) -> {ok, NewState}

Convert process state when code is changed

deactivate/2

deactivate(Module, Context::#context{}) -> ok

Deactivate a module. The module is marked as deactivated and stopped when it was running.

dependencies/1

dependencies(M) -> any()

Return a module's dependencies as a tuple usable for z_toposort:sort/1.

dependency_sort/1

dependency_sort(Context) -> any()

Sort all modules on their dependencies (with sub sort the module's priority)

get_modules/1

get_modules(Context) -> any()

Return the list of all modules running.

get_modules_status/1

get_modules_status(Context) -> any()

Return the status of all running modules.

get_provided/1

get_provided(Context) -> any()

Return the list of all provided functionalities in running modules.

handle_call/3

handle_call(Message::Request, From, State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}

Return a list of all enabled modules managed by the z_supervisor

handle_cast/2

handle_cast(Message::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Sync enabled modules with loaded modules

handle_info/2

handle_info(Info, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Handling all non call/cast messages

init/1

init(Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initiates the server.

module_exists/1

module_exists(M) -> any()

Check if the code of a module exists. The database can hold module references to non-existing modules.

prio/1

prio(Module) -> integer()

Return the priority of a module. Default priority is 500, lower is higher priority. Never crash on a missing module.

prio_sort/1

prio_sort(ModuleProps::proplist()) -> proplist()

Sort the results of a scan on module priority first, module name next. The list is made up of {module, Values} tuples

reinstall/2

reinstall(Module, Context) -> any()

Reinstall the given module's schema, calling Module:manage_schema(install, Context); if that function exists.

remove_observers/3

remove_observers(Module, Pid, Context) -> any()

Remove the observers for a module, called before module is deactivated

restart/2

restart(Module, Context) -> any()

Shortcut, restart a module by deactivating and reactivating the module.

scan/1

scan(Context::#context{}) -> [{atom(), dirname()}]

Scan for a list of modules present in the site's module directories. A module is always a directory, the name of the directory is the same as the name of the module.

start_link/1

start_link(SiteProps::proplist()) -> {ok, Pid} | ignore | {error, Error}

Starts the module manager

startable/2

startable(M, Context) -> any()

terminate/2

terminate(Reason, State) -> void()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

title/1

title(M) -> any()

Get the title of a module.

upgrade/1

upgrade(Context::#context{}) -> ok

Reload the list of all modules, add processes if necessary.

whereis/2

whereis(Module, Context) -> any()

Return the pid of a running module


Generated by EDoc, Sep 2 2014, 23:03:35.