Skip to content

Commit

Permalink
Log error on retry
Browse files Browse the repository at this point in the history
  • Loading branch information
epytka committed Aug 6, 2021
1 parent a12cbea commit fa6e6ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion deps/rabbitmq_aws/src/rabbitmq_aws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ api_get_request_with_retries(Service, Path, SleepTime, Retries) ->
{error, Message, _} ->
case Retries of
0 -> {error, Message};
_ -> timer:sleep(SleepTime),
_ -> rabbit_log:warning("Encountered error when calling api ~p, retries remaining ~p", [Message, Retries]),
timer:sleep(SleepTime),
api_get_request_with_retries(Service, Path, SleepTime, Retries - 1)
end
end.
12 changes: 6 additions & 6 deletions deps/rabbitmq_aws/test/src/rabbitmq_aws_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ api_get_request_with_retries_test_() ->
{"AWS service API request succeeded",
fun() ->
State = #state{access_key = "ExpiredKey",
secret_access_key = "ExpiredAccessKey",
region = "us-east-1",
expiration = {{3016, 4, 1}, {12, 0, 0}}},
secret_access_key = "ExpiredAccessKey",
region = "us-east-1",
expiration = {{3016, 4, 1}, {12, 0, 0}}},
meck:expect(httpc, request, 4, {ok, {{"HTTP/1.0", 200, "OK"}, [{"content-type", "application/json"}], "{\"data\": \"value\"}"}}),
{ok, Pid} = rabbitmq_aws:start_link(),
rabbitmq_aws:set_region("us-east-1"),
Expand Down Expand Up @@ -529,9 +529,9 @@ api_get_request_with_retries_test_() ->
{"AWS service API request failed - API error",
fun() ->
State = #state{access_key = "ExpiredKey",
secret_access_key = "ExpiredAccessKey",
region = "us-east-1",
expiration = {{3016, 4, 1}, {12, 0, 0}}},
secret_access_key = "ExpiredAccessKey",
region = "us-east-1",
expiration = {{3016, 4, 1}, {12, 0, 0}}},
meck:expect(httpc, request, 4, {error, "invalid input"}),
{ok, Pid} = rabbitmq_aws:start_link(),
rabbitmq_aws:set_region("us-east-1"),
Expand Down

0 comments on commit fa6e6ac

Please sign in to comment.