From 4e8dfb48b730b93ee44fdc036062b98b051a117b Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Wed, 14 Feb 2024 17:43:48 +0100 Subject: [PATCH] fix: elvis problems --- .../src/emqx_bridge_hstreamdb_action_info.erl | 3 ++- .../src/emqx_bridge_hstreamdb_connector.erl | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_action_info.erl b/apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_action_info.erl index 66188110f..7aa6565fa 100644 --- a/apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_action_info.erl +++ b/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( diff --git a/apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_connector.erl b/apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_connector.erl index bb65089d7..8413e5ecd 100644 --- a/apps/emqx_bridge_hstreamdb/src/emqx_bridge_hstreamdb_connector.erl +++ b/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