chore(router): drop test-only `has_routes/1`
Seems that it's too much support work only for test purposes, where `lookup_routes/1` is nearly as usable.
This commit is contained in:
parent
5d51687dbf
commit
e85789306b
|
@ -50,7 +50,7 @@
|
||||||
-export([
|
-export([
|
||||||
match_routes/1,
|
match_routes/1,
|
||||||
lookup_routes/1,
|
lookup_routes/1,
|
||||||
has_routes/1
|
has_route/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([print_routes/1]).
|
-export([print_routes/1]).
|
||||||
|
@ -222,27 +222,6 @@ lookup_routes_regular(Topic) ->
|
||||||
match_to_route(M) ->
|
match_to_route(M) ->
|
||||||
#route{topic = emqx_topic_index:get_topic(M), dest = emqx_topic_index:get_id(M)}.
|
#route{topic = emqx_topic_index:get_topic(M), dest = emqx_topic_index:get_id(M)}.
|
||||||
|
|
||||||
-spec has_routes(emqx_types:topic()) -> boolean().
|
|
||||||
has_routes(Topic) when is_binary(Topic) ->
|
|
||||||
case is_unified_table_active() of
|
|
||||||
true ->
|
|
||||||
has_routes_unified(Topic);
|
|
||||||
false ->
|
|
||||||
has_routes_regular(Topic)
|
|
||||||
end.
|
|
||||||
|
|
||||||
has_routes_unified(Topic) ->
|
|
||||||
Pat = #routeidx{entry = emqx_topic_index:mk_key(Topic, '$1'), _ = '_'},
|
|
||||||
case ets:match(?ROUTE_TAB_UNIFIED, Pat, 1) of
|
|
||||||
{[_], _} ->
|
|
||||||
true;
|
|
||||||
_ ->
|
|
||||||
false
|
|
||||||
end.
|
|
||||||
|
|
||||||
has_routes_regular(Topic) ->
|
|
||||||
ets:member(?ROUTE_TAB, Topic).
|
|
||||||
|
|
||||||
-spec has_route(emqx_types:topic(), dest()) -> boolean().
|
-spec has_route(emqx_types:topic(), dest()) -> boolean().
|
||||||
has_route(Topic, Dest) ->
|
has_route(Topic, Dest) ->
|
||||||
case is_unified_table_active() of
|
case is_unified_table_active() of
|
||||||
|
|
|
@ -1094,7 +1094,7 @@ t_multi_streams_unsub(Config) ->
|
||||||
?retry(
|
?retry(
|
||||||
_Sleep2 = 100,
|
_Sleep2 = 100,
|
||||||
_Attempts2 = 50,
|
_Attempts2 = 50,
|
||||||
false = emqx_router:has_routes(Topic)
|
[] = emqx_router:lookup_routes(Topic)
|
||||||
),
|
),
|
||||||
|
|
||||||
case emqtt:publish_via(C, PubVia, Topic, #{}, <<6, 7, 8, 9>>, [{qos, PubQos}]) of
|
case emqtt:publish_via(C, PubVia, Topic, #{}, <<6, 7, 8, 9>>, [{qos, PubQos}]) of
|
||||||
|
|
|
@ -176,9 +176,9 @@ t_print_routes(_) ->
|
||||||
?R:add_route(<<"+/+">>),
|
?R:add_route(<<"+/+">>),
|
||||||
?R:print_routes(<<"a/b">>).
|
?R:print_routes(<<"a/b">>).
|
||||||
|
|
||||||
t_has_routes(_) ->
|
t_has_route(_) ->
|
||||||
?R:add_route(<<"devices/+/messages">>, node()),
|
?R:add_route(<<"devices/+/messages">>, node()),
|
||||||
?assert(?R:has_routes(<<"devices/+/messages">>)),
|
?assert(?R:has_route(<<"devices/+/messages">>, node())),
|
||||||
?R:delete_route(<<"devices/+/messages">>).
|
?R:delete_route(<<"devices/+/messages">>).
|
||||||
|
|
||||||
t_unexpected(_) ->
|
t_unexpected(_) ->
|
||||||
|
|
|
@ -1054,7 +1054,7 @@ t_queue_subscription(Config) when is_list(Config) ->
|
||||||
begin
|
begin
|
||||||
ct:pal("routes: ~p", [ets:tab2list(emqx_route)]),
|
ct:pal("routes: ~p", [ets:tab2list(emqx_route)]),
|
||||||
%% FIXME: should ensure we have 2 subscriptions
|
%% FIXME: should ensure we have 2 subscriptions
|
||||||
true = emqx_router:has_routes(Topic)
|
[_] = emqx_router:lookup_routes(Topic)
|
||||||
end
|
end
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ t_queue_subscription(Config) when is_list(Config) ->
|
||||||
%% _Attempts0 = 50,
|
%% _Attempts0 = 50,
|
||||||
%% begin
|
%% begin
|
||||||
%% ct:pal("routes: ~p", [ets:tab2list(emqx_route)]),
|
%% ct:pal("routes: ~p", [ets:tab2list(emqx_route)]),
|
||||||
%% false = emqx_router:has_routes(Topic)
|
%% [] = emqx_router:lookup_routes(Topic)
|
||||||
%% end
|
%% end
|
||||||
%% ),
|
%% ),
|
||||||
ct:sleep(500),
|
ct:sleep(500),
|
||||||
|
|
|
@ -1928,7 +1928,7 @@ t_node_joins_existing_cluster(Config) ->
|
||||||
?retry(
|
?retry(
|
||||||
_Sleep2 = 100,
|
_Sleep2 = 100,
|
||||||
_Attempts2 = 50,
|
_Attempts2 = 50,
|
||||||
true = erpc:call(N2, emqx_router, has_routes, [MQTTTopic])
|
[] =/= erpc:call(N2, emqx_router, lookup_routes, [MQTTTopic])
|
||||||
),
|
),
|
||||||
{ok, SRef1} =
|
{ok, SRef1} =
|
||||||
snabbkaffe:subscribe(
|
snabbkaffe:subscribe(
|
||||||
|
|
Loading…
Reference in New Issue