refactor: use macros for status to avoid typos
This commit is contained in:
parent
baf2b96cbc
commit
44e7f2e9b2
|
@ -200,7 +200,7 @@ on_get_channel_status(
|
||||||
} = _State
|
} = _State
|
||||||
) when is_map_key(ChannelId, Channels) ->
|
) when is_map_key(ChannelId, Channels) ->
|
||||||
%% The channel should be ok as long as the MQTT client is ok
|
%% The channel should be ok as long as the MQTT client is ok
|
||||||
connected.
|
?status_connected.
|
||||||
|
|
||||||
on_get_channels(ResId) ->
|
on_get_channels(ResId) ->
|
||||||
emqx_bridge_v2:get_channels_for_connector(ResId).
|
emqx_bridge_v2:get_channels_for_connector(ResId).
|
||||||
|
@ -359,7 +359,7 @@ on_get_status(_ResourceId, State) ->
|
||||||
combine_status(Statuses)
|
combine_status(Statuses)
|
||||||
catch
|
catch
|
||||||
exit:timeout ->
|
exit:timeout ->
|
||||||
connecting
|
?status_connecting
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_status({_Pool, Worker}) ->
|
get_status({_Pool, Worker}) ->
|
||||||
|
@ -367,7 +367,7 @@ get_status({_Pool, Worker}) ->
|
||||||
{ok, Client} ->
|
{ok, Client} ->
|
||||||
emqx_bridge_mqtt_ingress:status(Client);
|
emqx_bridge_mqtt_ingress:status(Client);
|
||||||
{error, _} ->
|
{error, _} ->
|
||||||
disconnected
|
?status_disconnected
|
||||||
end.
|
end.
|
||||||
|
|
||||||
combine_status(Statuses) ->
|
combine_status(Statuses) ->
|
||||||
|
@ -379,7 +379,7 @@ combine_status(Statuses) ->
|
||||||
[Status | _] ->
|
[Status | _] ->
|
||||||
Status;
|
Status;
|
||||||
[] ->
|
[] ->
|
||||||
disconnected
|
?status_disconnected
|
||||||
end.
|
end.
|
||||||
|
|
||||||
mk_ingress_config(
|
mk_ingress_config(
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
-include_lib("emqx/include/logger.hrl").
|
-include_lib("emqx/include/logger.hrl").
|
||||||
-include_lib("emqx/include/emqx_mqtt.hrl").
|
-include_lib("emqx/include/emqx_mqtt.hrl").
|
||||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||||
|
-include_lib("emqx_resource/include/emqx_resource.hrl").
|
||||||
|
|
||||||
%% management APIs
|
%% management APIs
|
||||||
-export([
|
-export([
|
||||||
|
@ -234,13 +235,13 @@ status(Pid) ->
|
||||||
try
|
try
|
||||||
case proplists:get_value(socket, info(Pid)) of
|
case proplists:get_value(socket, info(Pid)) of
|
||||||
Socket when Socket /= undefined ->
|
Socket when Socket /= undefined ->
|
||||||
connected;
|
?status_connected;
|
||||||
undefined ->
|
undefined ->
|
||||||
connecting
|
?status_connecting
|
||||||
end
|
end
|
||||||
catch
|
catch
|
||||||
exit:{noproc, _} ->
|
exit:{noproc, _} ->
|
||||||
disconnected
|
?status_disconnected
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
Loading…
Reference in New Issue