Просмотр исходного кода

Drop unused config schema

bridge.$name.transport was added before we decided to derive
transport portocol based on the 'address' config.
i.e. when it's a remote erlang node, use gen_rpc
otherwise (must be IP or hostnmae), we should estabilish mqtt connection
spring2maz 7 лет назад
Родитель
Сommit
086a1d56b9
3 измененных файлов с 9 добавлено и 10 удалено
  1. 0 5
      priv/emqx.schema
  2. 5 2
      src/portal/emqx_portal.erl
  3. 4 3
      test/emqx_portal_SUITE.erl

+ 0 - 5
priv/emqx.schema

@@ -1512,11 +1512,6 @@ end}.
 %%--------------------------------------------------------------------
 %% Bridges
 %%--------------------------------------------------------------------
-{mapping, "bridge.$name.transport", "emqx.bridges", [
-  {default, mqtt_client},
-  {datatype, {enum, [emqx_portal, mqtt_client]}}
-]}.
-
 {mapping, "bridge.$name.address", "emqx.bridges", [
   {datatype, string}
 ]}.

+ 5 - 2
src/portal/emqx_portal.erl

@@ -353,8 +353,11 @@ do_ensure_present(forwards, Topic, _) ->
 do_ensure_present(subscriptions, {Topic, QoS},
                   #{connect_module := ConnectModule, connection := Conn}) ->
     case erlang:function_exported(ConnectModule, ensure_subscribed, 3) of
-        true -> ConnectModule:ensure_subscribed(Conn, Topic, QoS);
-        false -> {error, no_remote_subscription_support}
+        true ->
+            _ = ConnectModule:ensure_subscribed(Conn, Topic, QoS),
+            ok;
+        false ->
+            {error, no_remote_subscription_support}
     end.
 
 do_ensure_absent(forwards, Topic, _) ->

+ 4 - 3
test/emqx_portal_SUITE.erl

@@ -142,7 +142,10 @@ t_mqtt(Config) when is_list(Config) ->
     ClientId = <<"client-1">>,
     try
         ?assertEqual([{ForwardedTopic, 1}], emqx_portal:get_subscriptions(Pid)),
-        emqx_portal:ensure_subscription_present(Pid, ForwardedTopic2, _QoS = 1),
+        ok = emqx_portal:ensure_subscription_present(Pid, ForwardedTopic2, _QoS = 1),
+        ok = emqx_portal:ensure_forward_present(Pid, SendToTopic2),
+        %% TODO: investigate why it's necessary
+        timer:sleep(1000),
         ?assertEqual([{ForwardedTopic, 1},
                       {ForwardedTopic2, 1}], emqx_portal:get_subscriptions(Pid)),
         {ok, ConnPid} = emqx_mock_client:start_link(ClientId),
@@ -155,8 +158,6 @@ t_mqtt(Config) when is_list(Config) ->
                               emqx_session:publish(SPid, I, Msg)
                       end, Msgs),
         ok = receive_and_match_messages(Ref, Msgs),
-        ok = emqx_portal:ensure_forward_present(Pid, SendToTopic2),
-        timer:sleep(200),
         Msgs2 = lists:seq(Max + 1, Max * 2),
         lists:foreach(fun(I) ->
                               Msg = emqx_message:make(<<"client-2">>, ?QOS_1, SendToTopic2, integer_to_binary(I)),