From 5753ba1edf631b2dc9d645dd441259be43a56603 Mon Sep 17 00:00:00 2001 From: Micah Woods Date: Tue, 30 Jul 2024 13:30:19 -0400 Subject: [PATCH] Allow original request + n retries --- lib/broadway_cloud_pub_sub/pull_client.ex | 4 ++-- test/broadway_cloud_pub_sub/pull_client_test.exs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/broadway_cloud_pub_sub/pull_client.ex b/lib/broadway_cloud_pub_sub/pull_client.ex index 3a07e8d..7fd2fa7 100644 --- a/lib/broadway_cloud_pub_sub/pull_client.ex +++ b/lib/broadway_cloud_pub_sub/pull_client.ex @@ -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)} @@ -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 diff --git a/test/broadway_cloud_pub_sub/pull_client_test.exs b/test/broadway_cloud_pub_sub/pull_client_test.exs index fdacb05..56d0aa2 100644 --- a/test/broadway_cloud_pub_sub/pull_client_test.exs +++ b/test/broadway_cloud_pub_sub/pull_client_test.exs @@ -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