refactor(emqx_resource_instance): add function create_default_checker
This commit is contained in:
parent
8976e25b7a
commit
3b3f3fed76
|
@ -248,20 +248,21 @@ start_and_check(InstId, ResourceType, Config, Opts, Data) ->
|
|||
ets:insert(emqx_resource_instance, {InstId, Data2}),
|
||||
case maps:get(async_create, Opts, false) of
|
||||
false -> case do_health_check(Data2) of
|
||||
ok -> emqx_resource_health_check:create_checker(InstId,
|
||||
maps:get(health_check_interval, Opts, 15000),
|
||||
maps:get(health_check_timeout, Opts, 10000));
|
||||
ok -> create_default_checker(InstId, Opts);
|
||||
{error, Reason} -> {error, Reason}
|
||||
end;
|
||||
true -> emqx_resource_health_check:create_checker(InstId,
|
||||
maps:get(health_check_interval, Opts, 15000),
|
||||
maps:get(health_check_timeout, Opts, 10000))
|
||||
true -> create_default_checker(InstId, Opts)
|
||||
end;
|
||||
{error, Reason} ->
|
||||
ets:insert(emqx_resource_instance, {InstId, Data#{status => stopped}}),
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
create_default_checker(InstId, Opts) ->
|
||||
emqx_resource_health_check:create_checker(InstId,
|
||||
maps:get(health_check_interval, Opts, 15000),
|
||||
maps:get(health_check_timeout, Opts, 10000)).
|
||||
|
||||
do_stop(InstId) when is_binary(InstId) ->
|
||||
do_with_instance_data(InstId, fun do_stop/1, []);
|
||||
do_stop(#{state := undefined}) ->
|
||||
|
|
Loading…
Reference in New Issue