Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F140715
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/tesla/middleware/retry.ex b/lib/tesla/middleware/retry.ex
index 90f251a..507faa8 100644
--- a/lib/tesla/middleware/retry.ex
+++ b/lib/tesla/middleware/retry.ex
@@ -1,46 +1,46 @@
defmodule Tesla.Middleware.Retry do
@moduledoc """
Retry few times in case of connection refused error.
Example:
defmodule MyClient do
use Tesla
plug Tesla.Middleware.Retry, delay: 500, max_retries: 10
end
Options:
- `:delay` - number of milisecond to wait before retrying (defaults to 1000)
- `:max_retries` - maximum number of retries (defaults to 5)
"""
@defaults [
delay: 1000,
max_retries: 5
]
def call(env, next, opts) do
opts = opts || []
delay = Keyword.get(opts, :delay, @defaults[:delay])
max_retries = Keyword.get(opts, :max_retries, @defaults[:max_retries])
retry(env, next, delay, max_retries)
end
defp retry(env, next, _delay, retries) when retries <= 1 do
Tesla.run(env, next)
end
defp retry(env, next, delay, retries) do
Tesla.run(env, next)
rescue
error -> case error do
- %Tesla.Error{reason: :econnrefused} ->
+ %Tesla.Error{} ->
:timer.sleep(delay)
retry(env, next, delay, retries - 1)
_ ->
reraise error, System.stacktrace
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jan 21, 6:21 AM (1 d, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55669
Default Alt Text
(1 KB)
Attached To
Mode
R28 tesla
Attached
Detach File
Event Timeline
Log In to Comment