Page MenuHomePhorge

No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None
diff --git a/lib/tesla/middleware/retry.ex b/lib/tesla/middleware/retry.ex
index fe578a3..6e39210 100644
--- a/lib/tesla/middleware/retry.ex
+++ b/lib/tesla/middleware/retry.ex
@@ -1,47 +1,47 @@
defmodule Tesla.Middleware.Retry do
@behaviour Tesla.Middleware
@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 milliseconds 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
- ex in Tesla.Error ->
+ Tesla.Error ->
:timer.sleep(delay)
retry(env, next, delay, retries - 1)
error ->
reraise error, System.stacktrace
end
end

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 24, 2:10 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39421
Default Alt Text
(1 KB)

Event Timeline