Updated HTTP provider to use slice settings for timeout configuration

Ensures this provider uses the slice settings as defaults so none of this is hard coded. This also allows folks to tweak these settings via the environment variables (as mentioned in the previous commit).

Issue: 309
Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2026-05-12 08:37:21 -06:00
parent 776254fe33
commit 8ee733f9a2
+5 -1
View File
@@ -9,8 +9,12 @@ Hanami.app.register_provider :http do
start do
slice.start :logger
connect, read, write = slice[:settings].to_h.values_at :http_timeout_connect,
:http_timeout_read,
:http_timeout_write
http = ConnectionPool::Wrapper.new size: ENV.fetch("HANAMI_MAX_THREADS", 5) do
HTTP.timeout(connect: 2, read: 10, write: 10)
HTTP.timeout(connect:, read:, write:)
.use(:auto_inflate)
.use(logging: {logger: slice[:logger]})
.headers("User-Agent" => "http.rb/#{HTTP::VERSION} (#{Hanami.app.app_name})")