Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/finch/pool_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,23 @@ defmodule Finch.PoolManager do
|> Map.get(shp, default)
|> maybe_drop_tls_options(shp)
|> maybe_add_hostname(shp)
|> maybe_update_count(shp)
end

defp maybe_update_count(%{count: count, mod: Finch.HTTP2.Pool} = config, {scheme, host, port}) do
with {:ok, conn} <- Mint.HTTP2.connect(scheme, host, port) do
max_concurrent_streams =
Mint.HTTP2.get_server_setting(conn, :max_concurrent_streams) || count

count = min(count, max_concurrent_streams)
Map.put(config, :count, count)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how the stream count is getting utilised in the pool selection.

else
_ -> config
end
end

defp maybe_update_count(config, _), do: config

# Drop TLS options from :conn_opts for default pools with :http scheme,
# otherwise you will get :badarg error from :gen_tcp
defp maybe_drop_tls_options(config, {:http, _, _} = _shp) when is_map(config) do
Expand Down
3 changes: 3 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tools]
elixir = "latest"
erlang = "latest"