From 839e7b35cbb5b4102aec28be09ae1c952b354540 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi <16166434+thalesmg@users.noreply.github.com> Date: Mon, 5 Oct 2026 09:07:50 -0300 Subject: [PATCH 1/2] chore: support infinity health check timeout --- changelog.md | 4 ++++ src/ehttpc.erl | 9 +++++++-- test/ehttpc_tests.erl | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 877d9fa..047f01c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # ehttpc changes +## 0.7.8 + +- Made it possible to call `ehttpc:health_check` with a timeout of `infinity`. + ## 0.7.7 - Added TCP keepalive for the `keepalive` pool option, which used to be ignored. On Linux diff --git a/src/ehttpc.erl b/src/ehttpc.erl index fa58e43..948ac6d 100644 --- a/src/ehttpc.erl +++ b/src/ehttpc.erl @@ -146,9 +146,9 @@ get_state(Worker, Style) when is_pid(Worker) -> start_link(Pool, Id, Opts) -> gen_server:start_link(?MODULE, [Pool, Id, Opts], []). --spec health_check(pid(), integer()) -> ok | {error, term()}. +-spec health_check(pid(), timeout()) -> ok | {error, term()}. health_check(Worker, Timeout) -> - CallTimeout = Timeout + timer:seconds(2), + CallTimeout = health_check_call_timeout(Timeout), try gen_server:call(Worker, {health_check, Timeout}, CallTimeout) catch @@ -1246,6 +1246,11 @@ enqueue_latest_fn(_) -> fresh_expire_at(Timeout) when Timeout =:= infinity; is_integer(Timeout) -> {now_(), Timeout}. +health_check_call_timeout(infinity) -> + infinity; +health_check_call_timeout(Timeout) when is_integer(Timeout) -> + Timeout + timer:seconds(2). + parse_proxy_opts(Opts) -> %% Target host and port case proplists:get_value(proxy, Opts, undefined) of diff --git a/test/ehttpc_tests.erl b/test/ehttpc_tests.erl index 85901f1..141594e 100644 --- a/test/ehttpc_tests.erl +++ b/test/ehttpc_tests.erl @@ -448,7 +448,26 @@ health_check_test_() -> ) end ) - end} + end}, + %% infinity timeout + {timeout, 20, + ?_test( + ?WITH( + #{ + port => Port, + name => ?FUNCTION_NAME, + delay => 0 + }, + pool_opts(Port, true), + begin + Worker = ehttpc_pool:pick_worker(?POOL), + ?assertEqual( + ok, + ehttpc:health_check(Worker, infinity) + ) + end + ) + )} ]. health_check_abnormal_test_() -> From f3574d7fa22a9da8a78aa83969354d9a37ccc499 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi <16166434+thalesmg@users.noreply.github.com> Date: Mon, 5 Oct 2026 09:16:59 -0300 Subject: [PATCH 2/2] test: bump snabbkaffe -> 1.0.11 --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index df329c6..aa24c28 100644 --- a/rebar.config +++ b/rebar.config @@ -5,7 +5,7 @@ {deps, [ {gun, "2.1.0"}, {gproc, {git, "https://github.com/emqx/gproc", {tag, "0.9.0.1"}}}, - {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.10"}}} + {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.11"}}} ]}. {erl_opts, [