chore(bridge_v2): make fixes thanks to PR comments from @thalesmg
This commit is contained in:
parent
95f3b94ac3
commit
edb1d37e67
|
@ -458,7 +458,7 @@ health_check(ResId) ->
|
||||||
emqx_resource_manager:health_check(ResId).
|
emqx_resource_manager:health_check(ResId).
|
||||||
|
|
||||||
-spec channel_health_check(resource_id(), channel_id()) ->
|
-spec channel_health_check(resource_id(), channel_id()) ->
|
||||||
#{status := channel_status(), error := term(), any() := any()}.
|
#{status := channel_status(), error := term(), any() => any()}.
|
||||||
channel_health_check(ResId, ChannelId) ->
|
channel_health_check(ResId, ChannelId) ->
|
||||||
emqx_resource_manager:channel_health_check(ResId, ChannelId).
|
emqx_resource_manager:channel_health_check(ResId, ChannelId).
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ health_check(ResId) ->
|
||||||
safe_call(ResId, health_check, ?T_OPERATION).
|
safe_call(ResId, health_check, ?T_OPERATION).
|
||||||
|
|
||||||
-spec channel_health_check(resource_id(), channel_id()) ->
|
-spec channel_health_check(resource_id(), channel_id()) ->
|
||||||
#{status := channel_status(), error := term(), any() := any()}.
|
#{status := channel_status(), error := term(), any() => any()}.
|
||||||
channel_health_check(ResId, ChannelId) ->
|
channel_health_check(ResId, ChannelId) ->
|
||||||
%% Do normal health check first to trigger health checks for channels
|
%% Do normal health check first to trigger health checks for channels
|
||||||
%% and update the cached health status for the channels
|
%% and update the cached health status for the channels
|
||||||
|
@ -464,7 +464,7 @@ handle_event(
|
||||||
handle_event(
|
handle_event(
|
||||||
{call, From}, {remove_channel, ChannelId}, _State, Data
|
{call, From}, {remove_channel, ChannelId}, _State, Data
|
||||||
) ->
|
) ->
|
||||||
handle_not_connected_or_connecting_remove_channel(From, ChannelId, Data);
|
handle_not_connected_and_not_connecting_remove_channel(From, ChannelId, Data);
|
||||||
handle_event(
|
handle_event(
|
||||||
{call, From}, get_channels, _State, Data
|
{call, From}, get_channels, _State, Data
|
||||||
) ->
|
) ->
|
||||||
|
@ -706,14 +706,13 @@ handle_add_channel(From, Data, ChannelId, Config) ->
|
||||||
of
|
of
|
||||||
false ->
|
false ->
|
||||||
%% The channel is not installed in the connector state
|
%% The channel is not installed in the connector state
|
||||||
%% We need insert it into the channels map and let the health check
|
%% We insert it into the channels map and let the health check
|
||||||
%% take care of the rest
|
%% take care of the rest
|
||||||
NewChannels = maps:put(ChannelId, channel_status_new_with_config(Config), Channels),
|
NewChannels = maps:put(ChannelId, channel_status_new_with_config(Config), Channels),
|
||||||
NewData = Data#data{added_channels = NewChannels},
|
NewData = Data#data{added_channels = NewChannels},
|
||||||
{keep_state, update_state(NewData, Data), [
|
{keep_state, update_state(NewData, Data), [
|
||||||
{reply, From, ok}, {state_timeout, 0, health_check}
|
{reply, From, ok}, {state_timeout, 0, health_check}
|
||||||
]};
|
]};
|
||||||
%%handle_add_channel_need_insert(From, Data, ChannelId, Data, ChannelConfig);
|
|
||||||
true ->
|
true ->
|
||||||
%% The channel is already installed in the connector state
|
%% The channel is already installed in the connector state
|
||||||
%% We don't need to install it again
|
%% We don't need to install it again
|
||||||
|
@ -770,9 +769,10 @@ handle_remove_channel_exists(From, ChannelId, Data) ->
|
||||||
{keep_state_and_data, [{reply, From, Error}]}
|
{keep_state_and_data, [{reply, From, Error}]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
handle_not_connected_or_connecting_remove_channel(From, ChannelId, Data) ->
|
handle_not_connected_and_not_connecting_remove_channel(From, ChannelId, Data) ->
|
||||||
%% When state is not connected or connecting the channel will be removed
|
%% When state is not connected and not connecting the channel will be removed
|
||||||
%% from the channels map but nothing else will happen.
|
%% from the channels map but nothing else will happen since the channel
|
||||||
|
%% is not addded/installed in the resource state.
|
||||||
Channels = Data#data.added_channels,
|
Channels = Data#data.added_channels,
|
||||||
NewChannels = maps:remove(ChannelId, Channels),
|
NewChannels = maps:remove(ChannelId, Channels),
|
||||||
NewData = Data#data{added_channels = NewChannels},
|
NewData = Data#data{added_channels = NewChannels},
|
||||||
|
|
Loading…
Reference in New Issue