Skip to content

Commit

Permalink
Merge pull request #3505 from esl/mim_router
Browse files Browse the repository at this point in the history
ets-backed mongoose_router
  • Loading branch information
arcusfelis authored Jan 19, 2022
2 parents bb0ae51 + 4e9d66f commit 8ef7d9a
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 216 deletions.
8 changes: 4 additions & 4 deletions big_tests/tests/dynamic_domains_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end_per_suite(Config0) ->
uncluster_nodes(?CLUSTER_NODES, Config).

init_per_group(with_mod_dynamic_domains_test, Config) ->
MockedModules = [mod_dynamic_domains_test, ejabberd_router],
MockedModules = [mod_dynamic_domains_test, mongoose_router],
[ok = rpc(mim(), meck, new, [Module, [passthrough, no_link]])
|| Module <- MockedModules],
dynamic_modules:start(?HOST_TYPE, mod_dynamic_domains_test,
Expand Down Expand Up @@ -127,7 +127,7 @@ packet_handling_for_subdomain(Config) ->

%% check that subdomain is not served after the parent domain removal
remove_domains(?TEST_NODES, [NewDomain]),
rpc(mim(), meck, wait, [ejabberd_router, unregister_route, [NewSubdomain], 500]),
rpc(mim(), meck, wait, [mongoose_router, unregister_route, [NewSubdomain], 500]),
IQ = escalus_stanza:iq(NewSubdomain, <<"get">>, [QueryEl]),
escalus:send(Alice, IQ),
Stanza = escalus:wait_for_stanza(Alice, 10000),
Expand Down Expand Up @@ -157,7 +157,7 @@ iq_handling_for_domain(Config) ->

%% check that domain is not served removal
remove_domains(?TEST_NODES, [NewDomain]),
rpc(mim(), meck, wait, [ejabberd_router, unregister_route, [NewDomain], 500]),
rpc(mim(), meck, wait, [mongoose_router, unregister_route, [NewDomain], 500]),
IQ = escalus_stanza:iq(NewDomain, <<"get">>, [QueryEl]),
escalus:send(Alice, IQ),
Stanza = escalus:wait_for_stanza(Alice, 10000),
Expand Down Expand Up @@ -189,7 +189,7 @@ iq_handling_for_subdomain(Config) ->

%% check that subdomain is not served after the parent domain removal
remove_domains(?TEST_NODES, [NewDomain]),
rpc(mim(), meck, wait, [ejabberd_router, unregister_route, [NewSubdomain], 500]),
rpc(mim(), meck, wait, [mongoose_router, unregister_route, [NewSubdomain], 500]),
IQ = escalus_stanza:iq(NewSubdomain, <<"get">>, [QueryEl]),
escalus:send(Alice, IQ),
Stanza = escalus:wait_for_stanza(Alice, 10000),
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/push_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,12 @@ start_route_listener(Config) ->
push_form_ns => push_helper:push_form_type() },
Handler = rpc(mongoose_packet_handler, new, [?MODULE, #{state => State}]),
Domain = pubsub_domain(Config),
rpc(ejabberd_router, register_route, [Domain, Handler]),
rpc(mongoose_router, register_route, [Domain, Handler]),
Config.

stop_route_listener(Config) ->
Domain = pubsub_domain(Config),
rpc(ejabberd_router, unregister_route, [Domain]).
rpc(mongoose_router, unregister_route, [Domain]).

process_packet(_Acc, _From, To, El, #{state := State}) ->
#{ pid := TestCasePid, pub_options_ns := PubOptionsNS, push_form_ns := PushFormNS } = State,
Expand Down
2 changes: 1 addition & 1 deletion src/config/mongoose_config_spec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ general_defaults() ->
<<"sm_backend">> => {mnesia, []},
<<"rdbms_server_type">> => generic,
<<"mongooseimctl_access_commands">> => [],
<<"routing_modules">> => ejabberd_router:default_routing_modules(),
<<"routing_modules">> => mongoose_router:default_routing_modules(),
<<"replaced_wait_timeout">> => 2000,
<<"hide_service_name">> => false}.

Expand Down
4 changes: 2 additions & 2 deletions src/domain/mongoose_lazy_routing.erl
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ add_subdomain(#{subdomain := Subdomain, host_type := HostType,
IQs = get_iqs(#iq_table_key{host_type = HostType,
subdomain_pattern = SubdomainPattern}),
register_iqs(IQs, [SubdomainElement]),
ejabberd_router:register_route(Subdomain, PacketHandler);
mongoose_router:register_route(Subdomain, PacketHandler);
false ->
%% we should never get here, but it's ok to just ignore this.
ok
Expand All @@ -385,7 +385,7 @@ handle_maybe_remove_subdomain(#{subdomain := Subdomain, host_type := HostType,
subdomain_pattern := SubdomainPattern}) ->
case ets:lookup(?ROUTING_TABLE, Subdomain) of
[{Domain, {HostType, SubdomainPattern}} = SubdomainElement] ->
ejabberd_router:unregister_route(Domain),
mongoose_router:unregister_route(Domain),
IQs = get_iqs(#iq_table_key{host_type = HostType,
subdomain_pattern = SubdomainPattern}),
unregister_iqs(IQs, [SubdomainElement]),
Expand Down
1 change: 1 addition & 0 deletions src/ejabberd_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ start(normal, _Args) ->
mongoose_commands:init(),
mongoose_service:start(),
mongoose_config:start(),
mongoose_router:start(),
mongoose_logs:set_global_loglevel(mongoose_config:get_opt(loglevel)),
mongoose_deprecations:start(),
{ok, _} = Sup = ejabberd_sup:start_link(),
Expand Down
4 changes: 2 additions & 2 deletions src/ejabberd_local.erl
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ cancel_timer(TRef) ->
end.

do_register_host(Host) ->
ejabberd_router:register_route(Host, mongoose_packet_handler:new(?MODULE)).
mongoose_router:register_route(Host, mongoose_packet_handler:new(?MODULE)).

do_unregister_host(Host) ->
ejabberd_router:unregister_route(Host).
mongoose_router:unregister_route(Host).
Loading

0 comments on commit 8ef7d9a

Please sign in to comment.