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

Convert mod_carboncopy to use maps as options #3602

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/mod_carboncopy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ is_carbon_copy(Packet) ->
_ -> false
end.

start(HostType, Opts) ->
%% execute disable/enable actions in the c2s process itself
IQDisc = gen_mod:get_opt(iqdisc, Opts, no_queue),
%% Default IQDisc is no_queue:
%% executes disable/enable actions in the c2s process itself
start(HostType, #{iqdisc := IQDisc}) ->
ejabberd_hooks:add(hooks(HostType)),
gen_iq_handler:add_iq_handler_for_domain(HostType, ?NS_CC_2, ejabberd_sm,
fun ?MODULE:iq_handler2/5, #{}, IQDisc),
Expand All @@ -97,7 +97,10 @@ hooks(HostType) ->

-spec config_spec() -> mongoose_config_spec:config_section().
config_spec() ->
#section{items = #{<<"iqdisc">> => mongoose_config_spec:iqdisc()}}.
#section{
format_items = map,
items = #{<<"iqdisc">> => mongoose_config_spec:iqdisc()},
defaults = #{<<"iqdisc">> => no_queue}}.

-spec disco_local_features(mongoose_disco:feature_acc()) -> mongoose_disco:feature_acc().
disco_local_features(Acc = #{node := <<>>}) ->
Expand Down
6 changes: 4 additions & 2 deletions test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ all_modules() ->
validity_period => #{access => #{unit => minutes, value => 13},
refresh => #{unit => days, value => 13}},
iqdisc => one_queue},
mod_carboncopy => [{iqdisc, no_queue}],
mod_carboncopy => #{iqdisc => no_queue},
mod_mam =>
mod_config(mod_mam,
#{archive_chat_markers => true,
Expand Down Expand Up @@ -675,7 +675,7 @@ pgsql_modules() ->
#{mod_adhoc => default_mod_config(mod_adhoc),
mod_amp => [], mod_blocking => default_mod_config(mod_blocking),
mod_bosh => default_mod_config(mod_bosh),
mod_carboncopy => [], mod_commands => [],
mod_carboncopy => default_mod_config(mod_carboncopy), mod_commands => [],
mod_disco => mod_config(mod_disco, #{users_can_see_hidden_services => false}),
mod_last => mod_config(mod_last, #{backend => rdbms}),
mod_muc_commands => [], mod_muc_light_commands => [],
Expand Down Expand Up @@ -857,6 +857,8 @@ default_mod_config(mod_caps) ->
cache_life_time => timer:hours(24) div 1000};
default_mod_config(mod_csi) ->
#{buffer_max => 20};
default_mod_config(mod_carboncopy) ->
#{iqdisc => no_queue};
default_mod_config(mod_disco) ->
#{extra_domains => [], server_info => [],
users_can_see_hidden_services => true, iqdisc => one_queue};
Expand Down
2 changes: 1 addition & 1 deletion test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ mod_cache_users(_Config) ->
?errh(T(<<"number_of_segments">>, <<"infinity">>)).

mod_carboncopy(_Config) ->
check_iqdisc(mod_carboncopy).
check_iqdisc_map(mod_carboncopy).

mod_csi(_Config) ->
check_module_defaults(mod_csi),
Expand Down