Kjell Winblad 1 год назад
Родитель
Сommit
4e8dfb48b7

+ 2 - 1
apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_action_info.erl

@@ -74,7 +74,8 @@ connector_action_config_to_bridge_v1_config(ConnectorConfig, ActionConfig) ->
     ),
     BridgeV1Config4 = maps:put(<<"pool_size">>, PoolSize, BridgeV1Config3),
 
-    %% Move the fields stream, partition_key and record_template from parameters in ActionConfig to the top level in BridgeV1Config
+    %% Move the fields stream, partition_key and record_template from
+    %% parameters in ActionConfig to the top level in BridgeV1Config
     lists:foldl(
         fun(Field, Acc) ->
             emqx_utils_maps:deep_put(

+ 9 - 6
apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_connector.erl

@@ -270,12 +270,7 @@ client_options(Config = #{url := ServerURL, ssl := SSL}) ->
 check_status(ConnectorState) ->
     try start_client(ConnectorState) of
         {ok, Client} ->
-            try hstreamdb_client:echo(Client) of
-                ok -> ok;
-                {error, _} = ErrorEcho -> ErrorEcho
-            after
-                _ = hstreamdb:stop_client(Client)
-            end;
+            check_status_with_client(Client);
         {error, _} = StartClientError ->
             StartClientError
     catch
@@ -283,6 +278,14 @@ check_status(ConnectorState) ->
             {error, {ErrorType, Reason}}
     end.
 
+check_status_with_client(Client) ->
+    try hstreamdb_client:echo(Client) of
+        ok -> ok;
+        {error, _} = ErrorEcho -> ErrorEcho
+    after
+        _ = hstreamdb:stop_client(Client)
+    end.
+
 start_client(Opts) ->
     ClientOptions = maps:get(client_options, Opts),
     case hstreamdb:start_client(ClientOptions) of