@impl true
def handle_info({:gun_up, conn_pid, _protocol}, state) do
- # TODO: temp fix for gun MatchError https://github.com/ninenines/gun/issues/222
- # TODO: REMOVE LATER
- {key, conn} =
- try do
- %{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(conn_pid)
-
- host =
- case :inet.ntoa(host) do
- {:error, :einval} -> host
- ip -> ip
- end
-
- key = "#{scheme}:#{host}:#{port}"
- find_conn(state.conns, conn_pid, key)
- rescue
- MatcheError -> find_conn(state.conns, conn_pid)
+ %{origin_host: host, origin_scheme: scheme, origin_port: port} = Gun.info(conn_pid)
+
+ host =
+ case :inet.ntoa(host) do
+ {:error, :einval} -> host
+ ip -> ip
end
+ key = "#{scheme}:#{host}:#{port}"
+
state =
- with {true, key} <- {Process.alive?(conn_pid), key} do
+ with {key, conn} <- find_conn(state.conns, conn_pid, key),
+ {true, key} <- {Process.alive?(conn_pid), key} do
put_in(state.conns[key], %{
conn
| gun_state: :up,
@impl true
def handle_info({:DOWN, _ref, :process, conn_pid, reason}, state) do
- Logger.debug("received DOWM message for #{inspect(conn_pid)} reason -> #{inspect(reason)}")
+ Logger.debug("received DOWN message for #{inspect(conn_pid)} reason -> #{inspect(reason)}")
state =
with {key, conn} <- find_conn(state.conns, conn_pid) do