Skip to content
Merged
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
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ehttpc changes

## 0.7.1

- Add `pool` and `id` to the worker process label.

## 0.7.0

- Switch to `gun` 2.1.0.
Expand Down
2 changes: 1 addition & 1 deletion src/ehttpc.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, ehttpc, [
{description, "HTTP Client for Erlang/OTP"},
{vsn, "0.7.0"},
{vsn, "0.7.1"},
{registered, []},
{applications, [
kernel,
Expand Down
15 changes: 14 additions & 1 deletion src/ehttpc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

-behaviour(gen_server).

%% proc_lib:set_label/1 is not exported before OTP 27
-dialyzer([{nowarn_function, [init/1]}]).
-ignore_xref({proc_lib, set_label, 1}).

%% APIs
-export([
start_link/3,
Expand Down Expand Up @@ -262,6 +266,13 @@ init([Pool, Id, Opts0]) ->
max_inactive = MaxInactive
},
true = gproc_pool:connect_worker(ehttpc:name(Pool), {Pool, Id}),

case erlang:function_exported(proc_lib, set_label, 1) of
true ->
proc_lib:set_label({ehttpc, Pool, Id});
false ->
ignore
end,
{ok, start_check_inactive_timer(State)}.

handle_call({health_check, _}, _From, State = #state{gun_state = up}) ->
Expand Down Expand Up @@ -736,7 +747,9 @@ maybe_shoot(
]),
inactive_duration_threshold => MaxInactive,
inflight_requests => SentCount,
connection_pid => Client
connection_pid => Client,
pool => State#state.pool,
id => State#state.id
},
State
),
Expand Down
2 changes: 1 addition & 1 deletion src/ehttpc_worker_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ start_link(Pool, Opts) ->
init([Pool, Opts]) ->
WorkerSpec = fun(Id) ->
#{
id => {worker, Id},
id => {Pool, Id},
start => {ehttpc, start_link, [Pool, Id, Opts]},
restart => transient,
shutdown => 5000,
Expand Down