From 23192ee34e9376e3d545b26eabc64de30303a866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarl=20Andr=C3=A9=20H=C3=BCbenthal?= Date: Thu, 12 Oct 2023 18:33:59 +0200 Subject: [PATCH] refactor --- lib/reaper.ex | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/reaper.ex b/lib/reaper.ex index be798cb..76a9ea0 100644 --- a/lib/reaper.ex +++ b/lib/reaper.ex @@ -51,8 +51,14 @@ defmodule TestcontainersElixir.Reaper do end defp do_register(socket, {filter_key, filter_value}) do - :gen_tcp.send(socket, (docker_filter(filter_key, filter_value) <> "\n") |> IO.inspect()) - wait_for_ack(socket) + :gen_tcp.send( + socket, + ("#{:uri_string.quote(filter_key)}=#{:uri_string.quote(filter_value)}" <> "\n") + |> IO.inspect() + ) + + {:ok, "ACK\n"} = :gen_tcp.recv(socket, 0, 1_000) + :ok end @@ -74,10 +80,4 @@ defmodule TestcontainersElixir.Reaper do packet: :line ]) end - - defp docker_filter(key, value), do: "#{url_encode(key)}=#{url_encode(value)}" - - defp url_encode(string), do: :uri_string.quote(string) - - defp wait_for_ack(socket), do: {:ok, "ACK\n"} = :gen_tcp.recv(socket, 0, 1_000) end