refactor: clean up over complicated code
This commit cleans up overly complicated code and handles the case when the worker pool is empty. Thank you @thalesmg for suggesting this change. Co-authored-by: Thales Macedo Garitezi <thalesmg@gmail.com>
This commit is contained in:
parent
29e0ddefbc
commit
91514f3ace
|
@ -198,20 +198,12 @@ on_get_status(_InstanceId, #{pool_name := Pool} = State) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
status_result(Results, State) ->
|
status_result(Results, State) ->
|
||||||
case lists:all(fun(Res) -> Res =:= true end, Results) of
|
case lists:filter(fun(Res) -> Res =/= true end, Results) of
|
||||||
true ->
|
[] when Results =:= [] ->
|
||||||
|
?status_connecting;
|
||||||
|
[] ->
|
||||||
?status_connected;
|
?status_connected;
|
||||||
false ->
|
[{false, Error} | _] ->
|
||||||
{value, {false, Error}} =
|
|
||||||
lists:search(
|
|
||||||
fun
|
|
||||||
({false, _Error}) ->
|
|
||||||
true;
|
|
||||||
(_) ->
|
|
||||||
false
|
|
||||||
end,
|
|
||||||
Results
|
|
||||||
),
|
|
||||||
{?status_connecting, State, Error}
|
{?status_connecting, State, Error}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue