Skip to content

Commit

Permalink
refactor: clean up over complicated code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kjellwinblad and thalesmg committed Mar 12, 2024
1 parent a6605a4 commit 109258b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions apps/emqx_bridge_dynamo/src/emqx_bridge_dynamo_connector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,12 @@ on_get_status(_InstanceId, #{pool_name := Pool} = State) ->
end.

status_result(Results, State) ->
case lists:all(fun(Res) -> Res =:= true end, Results) of
true ->
case lists:filter(fun(Res) -> Res =/= true end, Results) of
[] when Results =:= [] ->
?status_connecting;
[] ->
?status_connected;
false ->
{value, {false, Error}} =
lists:search(
fun
({false, _Error}) ->
true;
(_) ->
false
end,
Results
),
[{false, Error} | _] ->
{?status_connecting, State, Error}
end.

Expand Down

0 comments on commit 109258b

Please sign in to comment.