fix: disconnected status in auto_reconnect = false
This commit is contained in:
parent
ca846d0c53
commit
a50980c496
|
@ -303,7 +303,13 @@ do_health_check(InstId) when is_binary(InstId) ->
|
||||||
|
|
||||||
do_health_check(_Group, #{state := undefined}) ->
|
do_health_check(_Group, #{state := undefined}) ->
|
||||||
{error, resource_not_initialized};
|
{error, resource_not_initialized};
|
||||||
do_health_check(Group, #{id := InstId, mod := Mod, state := ResourceState0} = Data) ->
|
do_health_check(Group,
|
||||||
|
#{id := InstId, mod := Mod, state := ResourceState0, config := Config} = Data) ->
|
||||||
|
FailedConnectStatus =
|
||||||
|
case maps:get(auto_reconnect, Config, true) of
|
||||||
|
true -> connecting;
|
||||||
|
false -> disconnected
|
||||||
|
end,
|
||||||
case emqx_resource:call_health_check(InstId, Mod, ResourceState0) of
|
case emqx_resource:call_health_check(InstId, Mod, ResourceState0) of
|
||||||
{ok, ResourceState1} ->
|
{ok, ResourceState1} ->
|
||||||
ets:insert(
|
ets:insert(
|
||||||
|
@ -313,17 +319,13 @@ do_health_check(Group, #{id := InstId, mod := Mod, state := ResourceState0} = Da
|
||||||
ok;
|
ok;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
logger:error("health check for ~p failed: ~p", [InstId, Reason]),
|
logger:error("health check for ~p failed: ~p", [InstId, Reason]),
|
||||||
ets:insert(
|
ets:insert(emqx_resource_instance,
|
||||||
emqx_resource_instance,
|
{InstId, Group, Data#{status => FailedConnectStatus}}),
|
||||||
{InstId, Group, Data#{status => connecting}}
|
|
||||||
),
|
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
{error, Reason, ResourceState1} ->
|
{error, Reason, ResourceState1} ->
|
||||||
logger:error("health check for ~p failed: ~p", [InstId, Reason]),
|
logger:error("health check for ~p failed: ~p", [InstId, Reason]),
|
||||||
ets:insert(
|
ets:insert(emqx_resource_instance,
|
||||||
emqx_resource_instance,
|
{InstId, Group, Data#{status => FailedConnectStatus, state => ResourceState1}}),
|
||||||
{InstId, Group, Data#{status => connecting, state => ResourceState1}}
|
|
||||||
),
|
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue