Skip to content

Commit

Permalink
Allow original request + n retries
Browse files Browse the repository at this point in the history
  • Loading branch information
mwoods79 committed Jul 30, 2024
1 parent 3227ff0 commit 5753ba1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/broadway_cloud_pub_sub/pull_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ defmodule BroadwayCloudPubSub.PullClient do
{:ok, Jason.decode!(body)}

{:ok, %Response{} = resp} ->
maybe_retry(resp, url, body, headers, config, action, payload, retries_left - 1)
maybe_retry(resp, url, body, headers, config, action, payload, retries_left)

{:error, err} ->
{:error, format_error(url, err)}
Expand All @@ -215,7 +215,7 @@ defmodule BroadwayCloudPubSub.PullClient do
defp maybe_retry(resp, url, body, headers, config, action, payload, retries_left) do
if should_retry(resp, config, retries_left) do
config |> retry_delay() |> Process.sleep()
execute(url, body, headers, config, action, payload, retries_left)
execute(url, body, headers, config, action, payload, retries_left - 1)
else
{:error, format_error(url, resp)}
end
Expand Down
2 changes: 1 addition & 1 deletion test/broadway_cloud_pub_sub/pull_client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ defmodule BroadwayCloudPubSub.PullClientTest do
opts: base_opts,
server: server
} do
multiple_errors_on_pubsub(server, error_count: 2, error_status: 502)
multiple_errors_on_pubsub(server, error_count: 3, error_status: 502)

{:ok, opts} =
base_opts
Expand Down

0 comments on commit 5753ba1

Please sign in to comment.