Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify MAM configuration #1112

Merged
merged 4 commits into from
Dec 14, 2016
Merged

Simplify MAM configuration #1112

merged 4 commits into from
Dec 14, 2016

Conversation

kzemek
Copy link
Contributor

@kzemek kzemek commented Dec 8, 2016

Configuration is simplified by introducing a new module, mod_mam_meta, that only parses its arguments and pulls in relevant MAM modules using deps/2 callback introduced in #1103. This way a unified configuration may be introduced without disrupting existing modules and providing full backwards compatibility with old configs.

fun({Module, _Args}) ->
gen_mod:stop_module(Host, Module)
end, Modules);
lists:foreach(fun({Mod, _}) -> gen_mod:stop_module(Host, Mod) end, Modules);
handle_local_hosts_config_del({{Key,_}, _} =El) ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 1079

@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) ->
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) ->
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]);
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) ->
Res = compare_modules(OldModules, NewModules),
reload_modules(Host, Res);
gen_mod_deps:replace_modules(Host, OldModules, NewModules);
handle_local_hosts_config_change({{Key,_Host},_Old,_New} = El) ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 1112

fun({Module, Args}) ->
gen_mod:start_module(Host, Module, Args)
end, Modules);
gen_mod_deps:start_modules(Host, Modules);
handle_local_hosts_config_add({{Key,_Host}, _} = El) ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 1054

@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) ->
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) ->
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]);
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 1110

@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) ->
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) ->
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]);
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) ->
Res = compare_modules(OldModules, NewModules),
reload_modules(Host, Res);
gen_mod_deps:replace_modules(Host, OldModules, NewModules);
handle_local_hosts_config_change({{Key,_Host},_Old,_New} = El) ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 1112

@@ -1114,8 +1108,7 @@ handle_local_hosts_config_change({{auth, Host}, OldVals, _}) ->
handle_local_hosts_config_change({{ldap, Host}, _OldConfig, NewConfig}) ->
ok = ejabberd_hooks:run_fold(host_config_update, Host, ok, [Host, ldap, NewConfig]);
handle_local_hosts_config_change({{modules,Host}, OldModules, NewModules}) ->
Res = compare_modules(OldModules, NewModules),
reload_modules(Host, Res);
gen_mod_deps:replace_modules(Host, OldModules, NewModules);
handle_local_hosts_config_change({{Key,_Host},_Old,_New} = El) ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Missing space right "," on line 1112

@kzemek kzemek changed the title Simplify mam configuration Simplify MAM configuration Dec 8, 2016
If you haven't chosen any of the above, skip the next part.
* **backend** (atom, default: `odbc`) - Database backend to use. `odbc`, `riak` and `cassandra` are supported.
* **add_archived_element** (atom, default: `false`) - Add `<archived/>` element from MAM v0.2.
* **is_complete_message** (module, default: `mod_mam_utils`) - Name of a module implementing [`is_complete_message/3` callback](#is_complete_message) that determines if the message should be archived.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's refactor this to is_archivable_message, because complete doesn't really makes sense IMO.

Deps = add_dep(mod_mam_odbc_user, [Type], Deps1),

lists:foldl(
fun
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting this fun to a function will most probably improve readability here.


call_is_archivable_message(Module, Dir, Packet) ->
M = mod_mam_muc_params:is_archivable_message(),
M:is_archivable_message(Module, Dir, Packet).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Remove the dynamic function call on line 985. Only modules that define callbacks should make dynamic calls.

M:is_complete_message(Module, Dir, Packet).
is_archivable_message(Module, Dir, Packet) ->
M = mod_mam_params:is_archivable_message(),
M:is_archivable_message(Module, Dir, Packet).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Remove the dynamic function call on line 1015. Only modules that define callbacks should make dynamic calls.


call_is_archivable_message(Module, Dir, Packet) ->
M = mod_mam_muc_params:is_archivable_message(),
M:is_archivable_message(Module, Dir, Packet).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Remove the dynamic function call on line 987. Only modules that define callbacks should make dynamic calls.


call_is_archivable_message(Module, Dir, Packet) ->
M = mod_mam_muc_params:is_archivable_message(),
M:is_archivable_message(Module, Dir, Packet).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Remove the dynamic function call on line 995. Only modules that define callbacks should make dynamic calls.

M = mod_mam_muc_params:is_complete_message(),
M:is_complete_message(Module, Dir, Packet).

call_is_archivable_message(Module, Dir, Packet) ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Compiler:

Warning: function call_is_archivable_message/3 is unused

Configuration is simplified by introducing a new module, mod_mam_meta, that only
parses its arguments and pulls in relevant MAM modules using deps/2 callback.
This way a unified configuration may be introduced without disrupting existing
modules and providing full backwards compatibility with old configs.
@michalwski michalwski merged commit e7bd692 into master Dec 14, 2016
@michalwski michalwski deleted the simplify-mam-configuration branch December 14, 2016 08:13
This was referenced Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants