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 23192ee commit 065ddae
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,28 @@ defmodule TestcontainersElixir.Reaper do

{:ok, socket} =
connection
|> connect_to_first_tcp_port(container, @ryuk_port)
|> create_socket(container, @ryuk_port)

{:ok, {container, socket}}
{:ok, socket}
end

@impl true
def handle_call({:register, filter}, _from, {_connection, socket} = state) do
{:reply, do_register(socket, filter), state}
def handle_call({:register, filter}, _from, socket) do
{:reply, do_register(socket, filter), socket}
end

defp do_register(socket, {filter_key, filter_value}) do
:gen_tcp.send(
socket,
("#{:uri_string.quote(filter_key)}=#{:uri_string.quote(filter_value)}" <> "\n")
|> IO.inspect()
"#{:uri_string.quote(filter_key)}=#{:uri_string.quote(filter_value)}" <> "\n"
)

{:ok, "ACK\n"} = :gen_tcp.recv(socket, 0, 1_000)

:ok
end

defp connect_to_first_tcp_port(
defp create_socket(
connection,
%DockerEngineAPI.Model.ContainerCreateResponse{Id: container_id},
port
Expand Down

0 comments on commit 065ddae

Please sign in to comment.