Merge pull request #7419 from EMQ-YangM/fix_health_check_crash
fix(emqx_resource_instance): improve the pattern match of the call_health_check
This commit is contained in:
commit
0f4f6b4fb4
|
@ -265,7 +265,7 @@ call_start(InstId, Mod, Config) ->
|
||||||
?SAFE_CALL(Mod:on_start(InstId, Config)).
|
?SAFE_CALL(Mod:on_start(InstId, Config)).
|
||||||
|
|
||||||
-spec call_health_check(instance_id(), module(), resource_state()) ->
|
-spec call_health_check(instance_id(), module(), resource_state()) ->
|
||||||
{ok, resource_state()} | {error, Reason:: term(), resource_state()}.
|
{ok, resource_state()} | {error, Reason:: term()} | {error, Reason:: term(), resource_state()}.
|
||||||
call_health_check(InstId, Mod, ResourceState) ->
|
call_health_check(InstId, Mod, ResourceState) ->
|
||||||
?SAFE_CALL(Mod:on_health_check(InstId, ResourceState)).
|
?SAFE_CALL(Mod:on_health_check(InstId, ResourceState)).
|
||||||
|
|
||||||
|
|
|
@ -295,6 +295,11 @@ do_health_check(Group, #{id := InstId, mod := Mod, state := ResourceState0} = Da
|
||||||
ets:insert(emqx_resource_instance,
|
ets:insert(emqx_resource_instance,
|
||||||
{InstId, Group, Data#{status => connected, state => ResourceState1}}),
|
{InstId, Group, Data#{status => connected, state => ResourceState1}}),
|
||||||
ok;
|
ok;
|
||||||
|
{error, Reason} ->
|
||||||
|
logger:error("health check for ~p failed: ~p", [InstId, Reason]),
|
||||||
|
ets:insert(emqx_resource_instance,
|
||||||
|
{InstId, Group, Data#{status => connecting}}),
|
||||||
|
{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(emqx_resource_instance,
|
ets:insert(emqx_resource_instance,
|
||||||
|
|
Loading…
Reference in New Issue