Skip to content

Commit

Permalink
chore: pr requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveigah committed Dec 11, 2023
1 parent be09ce4 commit b443c64
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/finch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defmodule Finch do

@type scheme() :: :http | :https

@type shp() :: {scheme(), host :: String.t(), port :: pos_integer()}
@type scheme_host_port() :: {scheme(), host :: String.t(), port :: :inet.port_number()}

@type request_opt() :: {:pool_timeout, pos_integer()} | {:receive_timeout, pos_integer()}

Expand Down Expand Up @@ -614,7 +614,7 @@ defmodule Finch do
}]
}
"""
@spec get_pool_status(name(), url :: String.t() | shp()) ::
@spec get_pool_status(name(), url :: String.t() | scheme_host_port()) ::
{:ok, list(Finch.HTTP1.PoolMetrics.t())}
| {:ok, list(Finch.HTTP2.PoolMetrics.t())}
| {:error, :not_found}
Expand Down
13 changes: 8 additions & 5 deletions lib/finch/http1/pool.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,14 @@ defmodule Finch.HTTP1.Pool do
{:error, :not_found}

count ->
result = Enum.map(1..count, &PoolMetrics.get_pool_status(finch_name, shp, &1))

if Enum.all?(result, &match?({:ok, _}, &1)),
do: {:ok, Enum.map(result, &elem(&1, 1))},
else: {:error, :not_found}
1..count
|> Enum.map(&PoolMetrics.get_pool_status(finch_name, shp, &1))
|> Enum.filter(&match?({:ok, _}, &1))
|> Enum.map(&elem(&1, 1))
|> case do
[] -> {:error, :not_found}
result -> {:ok, result}
end
end
end

Expand Down
13 changes: 8 additions & 5 deletions lib/finch/http2/pool.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ defmodule Finch.HTTP2.Pool do
{:error, :not_found}

count ->
result = Enum.map(1..count, &PoolMetrics.get_pool_status(finch_name, shp, &1))

if Enum.all?(result, &match?({:ok, _}, &1)),
do: {:ok, Enum.map(result, &elem(&1, 1))},
else: {:error, :not_found}
1..count
|> Enum.map(&PoolMetrics.get_pool_status(finch_name, shp, &1))
|> Enum.filter(&match?({:ok, _}, &1))
|> Enum.map(&elem(&1, 1))
|> case do
[] -> {:error, :not_found}
result -> {:ok, result}
end
end
end

Expand Down

0 comments on commit b443c64

Please sign in to comment.