chore(sysk): fix spellchecks & update change & more logs
This commit is contained in:
parent
ce83079c6b
commit
e93216fa62
|
@ -87,7 +87,7 @@ on_start(
|
||||||
?SLOG(info, #{
|
?SLOG(info, #{
|
||||||
msg => "starting_syskeeper_connector",
|
msg => "starting_syskeeper_connector",
|
||||||
connector => InstanceId,
|
connector => InstanceId,
|
||||||
config => redact(Config)
|
config => Config
|
||||||
}),
|
}),
|
||||||
|
|
||||||
HostCfg = emqx_schema:parse_server(Server, ?SYSKEEPER_HOST_OPTIONS),
|
HostCfg = emqx_schema:parse_server(Server, ?SYSKEEPER_HOST_OPTIONS),
|
||||||
|
@ -175,12 +175,12 @@ do_query(
|
||||||
syskeeper_connector_query_return,
|
syskeeper_connector_query_return,
|
||||||
#{error => Reason}
|
#{error => Reason}
|
||||||
),
|
),
|
||||||
%% ?SLOG(error, #{
|
?SLOG(error, #{
|
||||||
%% msg => "syskeeper_connector_do_query_failed",
|
msg => "syskeeper_connector_do_query_failed",
|
||||||
%% connector => InstanceId,
|
connector => InstanceId,
|
||||||
%% query => Query,
|
query => Query,
|
||||||
%% reason => Reason
|
reason => Reason
|
||||||
%% }),
|
}),
|
||||||
case Reason of
|
case Reason of
|
||||||
ecpool_empty ->
|
ecpool_empty ->
|
||||||
{error, {recoverable_error, Reason}};
|
{error, {recoverable_error, Reason}};
|
||||||
|
@ -188,10 +188,10 @@ do_query(
|
||||||
Result
|
Result
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
%% ?tp(
|
?tp(
|
||||||
%% syskeeper_connector_query_return,
|
syskeeper_connector_query_return,
|
||||||
%% #{result => Result}
|
#{result => Result}
|
||||||
%% ),
|
),
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -257,6 +257,3 @@ format_data([], Msg) ->
|
||||||
emqx_utils_json:encode(Msg);
|
emqx_utils_json:encode(Msg);
|
||||||
format_data(Tokens, Msg) ->
|
format_data(Tokens, Msg) ->
|
||||||
emqx_placeholder:proc_tmpl(Tokens, Msg).
|
emqx_placeholder:proc_tmpl(Tokens, Msg).
|
||||||
|
|
||||||
redact(Data) ->
|
|
||||||
emqx_utils:redact(Data, fun(Any) -> Any =:= aws_secret_access_key end).
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ parse_forward(<<_:4, AckVal:4, Bin/binary>>) ->
|
||||||
{ok, #{
|
{ok, #{
|
||||||
type => forward,
|
type => forward,
|
||||||
ack => ?I2B(AckVal),
|
ack => ?I2B(AckVal),
|
||||||
messages => emqx_bridge_syskeeper_frame:marshaller(MsgBin)
|
messages => marshaller(MsgBin)
|
||||||
}};
|
}};
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
|
|
|
@ -52,7 +52,7 @@ on_start(
|
||||||
} = Config
|
} = Config
|
||||||
) ->
|
) ->
|
||||||
?SLOG(info, #{
|
?SLOG(info, #{
|
||||||
msg => "starting_syskeeper_connector",
|
msg => "starting_syskeeper_proxy_server",
|
||||||
connector => InstanceId,
|
connector => InstanceId,
|
||||||
config => Config
|
config => Config
|
||||||
}),
|
}),
|
||||||
|
@ -78,7 +78,7 @@ on_start(
|
||||||
|
|
||||||
on_stop(InstanceId, _State) ->
|
on_stop(InstanceId, _State) ->
|
||||||
?SLOG(info, #{
|
?SLOG(info, #{
|
||||||
msg => "stopping_syskeeper_connector",
|
msg => "stopping_syskeeper_proxy_server",
|
||||||
connector => InstanceId
|
connector => InstanceId
|
||||||
}),
|
}),
|
||||||
case emqx_resource:get_allocated_resources(InstanceId) of
|
case emqx_resource:get_allocated_resources(InstanceId) of
|
||||||
|
@ -127,8 +127,11 @@ init([Transport, Socket, Conf]) ->
|
||||||
|
|
||||||
handle_event(internal, wait_ready, wait_ready, Data) ->
|
handle_event(internal, wait_ready, wait_ready, Data) ->
|
||||||
wait_ready(Data);
|
wait_ready(Data);
|
||||||
handle_event(state_timeout, handshake_timeout, handshake, _Data) ->
|
handle_event(state_timeout, handshake_timeout, handshake, Data) ->
|
||||||
%% ?LOG(error, "Handshake tiemout~n", []),
|
?SLOG(info, #{
|
||||||
|
msg => "syskeeper_proxy_server_handshake_timeout",
|
||||||
|
data => Data
|
||||||
|
}),
|
||||||
{stop, normal};
|
{stop, normal};
|
||||||
handle_event(internal, try_parse, running, Data) ->
|
handle_event(internal, try_parse, running, Data) ->
|
||||||
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));
|
try_parse(State, combine_buffer(Bin, Data));
|
||||||
handle_event(info, {tcp_closed, _}, _State, _Data) ->
|
handle_event(info, {tcp_closed, _}, _State, _Data) ->
|
||||||
{stop, normal};
|
{stop, normal};
|
||||||
handle_event(info, {tcp_error, _, _Reason}, _State, _Data) ->
|
handle_event(info, {tcp_error, Error, Reason}, _State, _Data) ->
|
||||||
%% ?LOG(warning, "TCP error, reason:~p~n", [Reason]),
|
?SLOG(warning, #{
|
||||||
|
msg => "syskeeper_proxy_server_tcp_error",
|
||||||
|
error => Error,
|
||||||
|
reason => Reason
|
||||||
|
}),
|
||||||
{stop, normal};
|
{stop, normal};
|
||||||
handle_event(_Event, _Content, _State, _Data) ->
|
handle_event(Event, Content, State, Data) ->
|
||||||
%% ?LOG(warning, "Unexpected event:~p, Context:~p, State:~p~n", [Event, Content, State]),
|
?SLOG(warning, #{
|
||||||
|
msg => "syskeeper_proxy_server_unexpected_event",
|
||||||
|
event => Event,
|
||||||
|
content => Content,
|
||||||
|
state => State,
|
||||||
|
data => Data
|
||||||
|
}),
|
||||||
keep_state_and_data.
|
keep_state_and_data.
|
||||||
|
|
||||||
-spec terminate(Reason :: term(), State :: state(), Data :: data()) ->
|
-spec terminate(Reason :: term(), State :: state(), Data :: data()) ->
|
||||||
|
@ -183,6 +196,11 @@ wait_ready(
|
||||||
{state_timeout, Timeout, handshake_timeout}};
|
{state_timeout, Timeout, handshake_timeout}};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
ok = Transport:fast_close(RawSocket),
|
ok = Transport:fast_close(RawSocket),
|
||||||
|
?SLOG(error, #{
|
||||||
|
msg => "syskeeper_proxy_server_listen_error",
|
||||||
|
transport => Transport,
|
||||||
|
reason => Reason
|
||||||
|
}),
|
||||||
{stop, Reason}
|
{stop, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -202,8 +220,13 @@ try_parse(State, #{buffer := Bin} = Data) ->
|
||||||
end;
|
end;
|
||||||
{error, incomplete} ->
|
{error, incomplete} ->
|
||||||
{keep_state, Data};
|
{keep_state, Data};
|
||||||
{error, _Reason} ->
|
{error, Reason} ->
|
||||||
%% ?LOG(warning, "Parse error, reason:~p, buffer:~p~n", [Reason, Bin]),
|
?SLOG(error, #{
|
||||||
|
msg => "syskeeper_proxy_server_try_parse_error",
|
||||||
|
state => State,
|
||||||
|
data => Data,
|
||||||
|
reason => Reason
|
||||||
|
}),
|
||||||
{stop, parse_error}
|
{stop, parse_error}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -230,9 +253,14 @@ do_forward(Ack, Messages, Data) ->
|
||||||
|
|
||||||
handle_parse_result({ok, Msg}, State, Data) ->
|
handle_parse_result({ok, Msg}, State, Data) ->
|
||||||
handle_packet(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),
|
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}.
|
{stop, parse_error}.
|
||||||
|
|
||||||
handle_parse_error(_, handshake, Data) ->
|
handle_parse_error(_, handshake, Data) ->
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Integrated Nari Syskeeper 2000 as a new bridge backend.
|
|
@ -294,3 +294,4 @@ OCPP
|
||||||
dnstream
|
dnstream
|
||||||
upstream
|
upstream
|
||||||
priv
|
priv
|
||||||
|
Syskeeper
|
||||||
|
|
Loading…
Reference in New Issue