From 410ede246381aa4a61e04a5292a1ec5bc7b7aad3 Mon Sep 17 00:00:00 2001 From: Waseem Awashra Date: Sun, 29 Mar 2026 20:40:21 +0300 Subject: [PATCH] add conn_max_idle_time and pool_timeout --- lib/hubspot/application.ex | 3 ++- lib/hubspot/common/api.ex | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/hubspot/application.ex b/lib/hubspot/application.ex index 81ecabe..48ee39d 100644 --- a/lib/hubspot/application.ex +++ b/lib/hubspot/application.ex @@ -5,7 +5,8 @@ defmodule Hubspot.Application do def start(_type, _args) do children = [ {Cachex, name: :hubspot_cache}, - {Finch, name: Hubspot.Common.API} + {Finch, + name: Hubspot.Common.API, pools: %{default: [conn_max_idle_time: :timer.seconds(340)]}} ] # See https://hexdocs.pm/elixir/Supervisor.html diff --git a/lib/hubspot/common/api.ex b/lib/hubspot/common/api.ex index 9b29ae0..675bc71 100644 --- a/lib/hubspot/common/api.ex +++ b/lib/hubspot/common/api.ex @@ -3,12 +3,13 @@ defmodule Hubspot.Common.API do @default_transport_retry_timeout 1_000 @retry_threshold 3 + @receive_timeout 6_000 + @pool_timeout 10_000 require Logger def request(type, url, body \\ nil, headers \\ [], opts \\ []) do - opts = Keyword.merge([receive_timeout: 6_000], opts) - opts = Keyword.merge([receive_timeout: 6_000], opts) + opts = Keyword.merge([receive_timeout: @receive_timeout, pool_timeout: @pool_timeout], opts) case :timer.tc(&do_send_request/5, [type, url, body, headers, opts]) do {time, {:ok, response}} ->