Bladeren bron

chore(sysk): fix spellchecks & update change & more logs

firest 2 jaren geleden
bovenliggende
commit
e93216fa62

+ 11 - 14
apps/emqx_bridge_syskeeper/src/emqx_bridge_syskeeper_connector.erl

@@ -87,7 +87,7 @@ on_start(
     ?SLOG(info, #{
         msg => "starting_syskeeper_connector",
         connector => InstanceId,
-        config => redact(Config)
+        config => Config
     }),
 
     HostCfg = emqx_schema:parse_server(Server, ?SYSKEEPER_HOST_OPTIONS),
@@ -175,12 +175,12 @@ do_query(
                 syskeeper_connector_query_return,
                 #{error => Reason}
             ),
-            %% ?SLOG(error, #{
-            %%     msg => "syskeeper_connector_do_query_failed",
-            %%     connector => InstanceId,
-            %%     query => Query,
-            %%     reason => Reason
-            %% }),
+            ?SLOG(error, #{
+                msg => "syskeeper_connector_do_query_failed",
+                connector => InstanceId,
+                query => Query,
+                reason => Reason
+            }),
             case Reason of
                 ecpool_empty ->
                     {error, {recoverable_error, Reason}};
@@ -188,10 +188,10 @@ do_query(
                     Result
             end;
         _ ->
-            %% ?tp(
-            %%     syskeeper_connector_query_return,
-            %%     #{result => Result}
-            %% ),
+            ?tp(
+                syskeeper_connector_query_return,
+                #{result => Result}
+            ),
             Result
     end.
 
@@ -257,6 +257,3 @@ format_data([], Msg) ->
     emqx_utils_json:encode(Msg);
 format_data(Tokens, Msg) ->
     emqx_placeholder:proc_tmpl(Tokens, Msg).
-
-redact(Data) ->
-    emqx_utils:redact(Data, fun(Any) -> Any =:= aws_secret_access_key end).

+ 1 - 1
apps/emqx_bridge_syskeeper/src/emqx_bridge_syskeeper_frame_v1.erl

@@ -63,7 +63,7 @@ parse_forward(<<_:4, AckVal:4, Bin/binary>>) ->
             {ok, #{
                 type => forward,
                 ack => ?I2B(AckVal),
-                messages => emqx_bridge_syskeeper_frame:marshaller(MsgBin)
+                messages => marshaller(MsgBin)
             }};
         Error ->
             Error

+ 40 - 12
apps/emqx_bridge_syskeeper/src/emqx_bridge_syskeeper_proxy_server.erl

@@ -52,7 +52,7 @@ on_start(
     } = Config
 ) ->
     ?SLOG(info, #{
-        msg => "starting_syskeeper_connector",
+        msg => "starting_syskeeper_proxy_server",
         connector => InstanceId,
         config => Config
     }),
@@ -78,7 +78,7 @@ on_start(
 
 on_stop(InstanceId, _State) ->
     ?SLOG(info, #{
-        msg => "stopping_syskeeper_connector",
+        msg => "stopping_syskeeper_proxy_server",
         connector => InstanceId
     }),
     case emqx_resource:get_allocated_resources(InstanceId) of
@@ -127,8 +127,11 @@ init([Transport, Socket, Conf]) ->
 
 handle_event(internal, wait_ready, wait_ready, Data) ->
     wait_ready(Data);
-handle_event(state_timeout, handshake_timeout, handshake, _Data) ->
-    %%    ?LOG(error, "Handshake tiemout~n", []),
+handle_event(state_timeout, handshake_timeout, handshake, Data) ->
+    ?SLOG(info, #{
+        msg => "syskeeper_proxy_server_handshake_timeout",
+        data => Data
+    }),
     {stop, normal};
 handle_event(internal, try_parse, running, Data) ->
     try_parse(running, Data);
@@ -136,11 +139,21 @@ handle_event(info, {tcp, _Socket, Bin}, State, Data) ->
     try_parse(State, combine_buffer(Bin, Data));
 handle_event(info, {tcp_closed, _}, _State, _Data) ->
     {stop, normal};
-handle_event(info, {tcp_error, _, _Reason}, _State, _Data) ->
-    %%    ?LOG(warning, "TCP error, reason:~p~n", [Reason]),
+handle_event(info, {tcp_error, Error, Reason}, _State, _Data) ->
+    ?SLOG(warning, #{
+        msg => "syskeeper_proxy_server_tcp_error",
+        error => Error,
+        reason => Reason
+    }),
     {stop, normal};
-handle_event(_Event, _Content, _State, _Data) ->
-    %%    ?LOG(warning, "Unexpected event:~p, Context:~p, State:~p~n", [Event, Content, State]),
+handle_event(Event, Content, State, Data) ->
+    ?SLOG(warning, #{
+        msg => "syskeeper_proxy_server_unexpected_event",
+        event => Event,
+        content => Content,
+        state => State,
+        data => Data
+    }),
     keep_state_and_data.
 
 -spec terminate(Reason :: term(), State :: state(), Data :: data()) ->
@@ -183,6 +196,11 @@ wait_ready(
                 {state_timeout, Timeout, handshake_timeout}};
         {error, Reason} ->
             ok = Transport:fast_close(RawSocket),
+            ?SLOG(error, #{
+                msg => "syskeeper_proxy_server_listen_error",
+                transport => Transport,
+                reason => Reason
+            }),
             {stop, Reason}
     end.
 
@@ -202,8 +220,13 @@ try_parse(State, #{buffer := Bin} = Data) ->
             end;
         {error, incomplete} ->
             {keep_state, Data};
-        {error, _Reason} ->
-            %%            ?LOG(warning, "Parse error, reason:~p, buffer:~p~n", [Reason, Bin]),
+        {error, Reason} ->
+            ?SLOG(error, #{
+                msg => "syskeeper_proxy_server_try_parse_error",
+                state => State,
+                data => Data,
+                reason => Reason
+            }),
             {stop, parse_error}
     end.
 
@@ -230,9 +253,14 @@ do_forward(Ack, Messages, Data) ->
 
 handle_parse_result({ok, Msg}, State, Data) ->
     handle_packet(Msg, State, Data);
-handle_parse_result({error, _Reason} = Error, State, Data) ->
+handle_parse_result({error, Reason} = Error, State, Data) ->
     handle_parse_error(Error, State, #{buffer := _Bin} = Data),
-    %%    ?LOG(warning, "Parse error, state:~p, reason:~p, buffer:~p~n", [State, Reason, Bin]),
+    ?SLOG(error, #{
+        msg => "syskeeper_proxy_server_parse_result_error",
+        state => State,
+        data => Data,
+        reason => Reason
+    }),
     {stop, parse_error}.
 
 handle_parse_error(_, handshake, Data) ->

+ 1 - 0
changes/ee/feat-11795.en.md

@@ -0,0 +1 @@
+Integrated Nari Syskeeper 2000 as a new bridge backend.

+ 1 - 0
scripts/spellcheck/dicts/emqx.txt

@@ -294,3 +294,4 @@ OCPP
 dnstream
 upstream
 priv
+Syskeeper