Current section
14 Versions
Jump to
Current section
14 Versions
Compare versions
7
files changed
+37
additions
-29
deletions
| @@ -31,3 +31,6 @@ CHANGELOG | |
| 31 31 | |
| 32 32 | ---- 0.2.6 / 2014-10-09 / retry-on-error --------------------------------------- |
| 33 33 | * retry with exponential backoff for 500 errors |
| 34 | + |
| 35 | + ---- 0.2.7 / 2014-10-15 / update-httpoison ------------------------------------- |
| 36 | + * update httpoison |
| @@ -1,5 +1,5 @@ | |
| 1 1 | --- |
| 2 2 | major: 0 |
| 3 3 | minor: 2 |
| 4 | - patch: 6 |
| 4 | + patch: 7 |
| 5 5 | pre: |
| @@ -12,9 +12,16 @@ | |
| 12 12 | <<"CHANGELOG.md">>,<<"VERSION.yml">>]}. |
| 13 13 | {<<"licenses">>,[<<"MIT">>]}. |
| 14 14 | {<<"links">>,#{<<"github">> => <<"https://github.com/adamkittelson/simplex">>}}. |
| 15 | + {<<"name">>,<<"simplex">>}. |
| 15 16 | {<<"requirements">>, |
| 16 | - #{<<"httpoison">> => #{<<"optional">> => nil,<<"requirement">> => <<"~> 0.4.2">>}, |
| 17 | - <<"poison">> => #{<<"optional">> => nil,<<"requirement">> => <<"~> 1.2.0">>}, |
| 18 | - <<"sweet_xml">> => #{<<"optional">> => nil,<<"requirement">> => <<"~> 0.1.1">>}, |
| 19 | - <<"timex">> => #{<<"optional">> => nil,<<"requirement">> => <<"~> 0.12.5">>}}}. |
| 20 | - {<<"version">>,<<"0.2.6">>}. |
| 17 | + #{<<"httpoison">> => #{<<"app">> => <<"httpoison">>, |
| 18 | + <<"optional">> => nil, |
| 19 | + <<"requirement">> => <<"~> 0.5.0">>}, |
| 20 | + <<"poison">> => #{<<"app">> => <<"poison">>,<<"optional">> => nil,<<"requirement">> => <<"~> 1.2.0">>}, |
| 21 | + <<"sweet_xml">> => #{<<"app">> => <<"sweet_xml">>, |
| 22 | + <<"optional">> => nil, |
| 23 | + <<"requirement">> => <<"~> 0.1.1">>}, |
| 24 | + <<"timex">> => #{<<"app">> => <<"timex">>, |
| 25 | + <<"optional">> => nil, |
| 26 | + <<"requirement">> => <<"~> 0.12.5">>}}}. |
| 27 | + {<<"version">>,<<"0.2.7">>}. |
| @@ -74,8 +74,8 @@ defmodule Simplex do | |
| 74 74 | |
| 75 75 | defp load_credentials_from_metadata do |
| 76 76 | try do |
| 77 | - %HTTPoison.Response{:body => role_name} = HTTPoison.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/", [], [timeout: 500]) |
| 78 | - %HTTPoison.Response{:body => body} = HTTPoison.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/#{role_name}", [], [timeout: 500]) |
| 77 | + %HTTPoison.Response{:body => role_name} = HTTPoison.get!("http://169.254.169.254/latest/meta-data/iam/security-credentials/", [], [timeout: 500]) |
| 78 | + %HTTPoison.Response{:body => body} = HTTPoison.get!("http://169.254.169.254/latest/meta-data/iam/security-credentials/#{role_name}", [], [timeout: 500]) |
| 79 79 | Poison.decode!(body) |
| 80 80 | rescue |
| 81 81 | _ -> |
| @@ -21,17 +21,14 @@ defmodule Simplex.Request do | |
| 21 21 | |
| 22 22 | def execute_with_retry(signed_request, attempts \\ 0, last_response \\ nil) |
| 23 23 | def execute_with_retry(signed_request, attempts, _last_response) when attempts < @max_attempts do |
| 24 | - try do |
| 25 | - attempts |> delay |> :timer.sleep |
| 26 | - case HTTPoison.get(signed_request, [], [timeout: 30000]) do |
| 27 | - %HTTPoison.Response{status_code: status_code} = response when status_code >= 500 and status_code < 600 -> |
| 28 | - execute_with_retry signed_request, attempts + 1, response |
| 29 | - response -> |
| 30 | - response |
| 31 | - end |
| 32 | - rescue |
| 33 | - e in HTTPoison.HTTPError -> e |
| 34 | - execute_with_retry signed_request, attempts + 1, e |
| 24 | + attempts |> delay |> :timer.sleep |
| 25 | + case HTTPoison.get(signed_request, [], [timeout: 30000]) do |
| 26 | + {:error, %HTTPoison.Response{status_code: status_code} = response} when status_code >= 500 and status_code < 600 -> |
| 27 | + execute_with_retry signed_request, attempts + 1, {:error, response} |
| 28 | + {:error, %HTTPoison.Error{} = e} -> |
| 29 | + execute_with_retry signed_request, attempts + 1, {:error, e} |
| 30 | + response -> |
| 31 | + response |
| 35 32 | end |
| 36 33 | end |
| 37 34 | def execute_with_retry(_signed_request, _attempts, last_response), do: last_response |
Loading more files…