We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 81fc12a commit 11dcf1dCopy full SHA for 11dcf1d
lib/ex_aws/request.ex
@@ -1,6 +1,8 @@
1
defmodule ExAws.Request do
2
require Logger
3
@max_attempts 10
4
+ @base_backoff_in_ms 10
5
+ @max_backoff_in_ms 10_000
6
7
@moduledoc """
8
Makes requests to AWS.
@@ -84,9 +86,11 @@ defmodule ExAws.Request do
84
86
{:attempt, attempt + 1}
85
87
end
88
- # TODO: make exponential
- # TODO: add jitter
89
def backoff(attempt) do
90
- :timer.sleep(attempt * 1000)
+ (@base_backoff_in_ms * :math.pow(2, attempt))
91
+ |> min(@max_backoff_in_ms)
92
+ |> trunc
93
+ |> :rand.uniform
94
+ |> :timer.sleep
95
96
0 commit comments