Skip to content

Commit

Permalink
retry register filter operation only 3 times
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 13, 2023
1 parent cdca855 commit d97df0b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule TestcontainersElixir.Reaper do
{:reply, register_filter(socket, filter), socket}
end

defp register_filter(socket, {filter_key, filter_value}) do
defp register_filter(socket, {filter_key, filter_value}, retries \\ 3) do
:gen_tcp.send(
socket,
"#{:uri_string.quote(filter_key)}=#{:uri_string.quote(filter_value)}" <> "\n"
Expand All @@ -50,9 +50,9 @@ defmodule TestcontainersElixir.Reaper do
{:ok, "ACK\n"} ->
:ok

{:error, :closed} ->
IO.puts("Connection was closed")
register_filter(socket, {filter_key, filter_value})
{:error, :closed} when retries > 0 ->
IO.puts("Connection was closed, retrying...")
register_filter(socket, {filter_key, filter_value}, retries - 1)

{:error, reason} ->
IO.puts("Error receiving data: #{inspect(reason)}")
Expand Down

0 comments on commit d97df0b

Please sign in to comment.