Skip to content

Commit

Permalink
run_finch: Add option to configure Finch :pool_max_idle_time (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko authored Nov 25, 2024
1 parent a044101 commit cdb7228
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/req.ex
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ defmodule Req do
* `:unix_socket` - if set, connect through the given UNIX domain socket.
* `:pool_max_idle_time` - the maximum number of milliseconds that a pool can be
idle before being terminated, used only by HTTP1 pools. Default to `:infinity`.
* `:finch_private` - a map or keyword list of private metadata to add to the Finch request. May be useful
for adding custom data when handling telemetry with `Finch.Telemetry`.
Expand Down
4 changes: 3 additions & 1 deletion lib/req/finch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ defmodule Req.Finch do
def pool_options(options) when is_map(options) do
connect_options = options[:connect_options] || []
inet6_options = options |> Map.take([:inet6]) |> Enum.to_list()
pool_options = options |> Map.take([:pool_max_idle_time]) |> Enum.to_list()

Req.Request.validate_options(
connect_options,
Expand Down Expand Up @@ -413,7 +414,8 @@ defmodule Req.Finch do
[:http1]
end

[protocols: protocols] ++
pool_options ++
[protocols: protocols] ++
if conn_opts != [] do
[conn_opts: conn_opts]
else
Expand Down
4 changes: 4 additions & 0 deletions lib/req/steps.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ defmodule Req.Steps do
:receive_timeout,
:pool_timeout,
:unix_socket,
:pool_max_idle_time,

# TODO: Remove on Req 1.0
:output,
Expand Down Expand Up @@ -750,6 +751,9 @@ defmodule Req.Steps do
* `:unix_socket` - if set, connect through the given UNIX domain socket.
* `:pool_max_idle_time` - the maximum number of milliseconds that a pool can be
idle before being terminated, used only by HTTP1 pools. Default to `:infinity`.
* `:finch_private` - a map or keyword list of private metadata to add to the Finch request.
May be useful for adding custom data when handling telemetry with `Finch.Telemetry`.
Expand Down

0 comments on commit cdb7228

Please sign in to comment.