Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 12, 2023
1 parent 6ac79df commit 23192ee
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit 23192ee

Please sign in to comment.