fix: ecpool worker exec dynamo health check fun

This commit is contained in:
JimMoen 2023-03-24 11:15:52 +08:00
parent 65f468f706
commit d0f0a93888
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
1 changed files with 3 additions and 8 deletions

View File

@ -31,8 +31,7 @@
connect/1,
do_get_status/1,
do_async_reply/2,
worker_do_query/4,
worker_do_get_status/1
worker_do_query/4
]).
-import(hoconsc, [mk/2, enum/1, ref/2]).
@ -165,18 +164,14 @@ on_get_status(_InstanceId, #{poolname := Pool}) ->
Health = emqx_plugin_libs_pool:health_check_ecpool_workers(Pool, fun ?MODULE:do_get_status/1),
status_result(Health).
do_get_status(Conn) ->
do_get_status(_Conn) ->
%% because the dynamodb driver connection process is the ecpool worker self
%% so we must call the checker function inside the worker
ListTables = ecpool_worker:exec(Conn, {?MODULE, worker_do_get_status, []}, infinity),
case ListTables of
case erlcloud_ddb2:list_tables() of
{ok, _} -> true;
_ -> false
end.
worker_do_get_status(_) ->
erlcloud_ddb2:list_tables().
status_result(_Status = true) -> connected;
status_result(_Status = false) -> connecting.