Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Created June 14, 2020 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krainboltgreene/8203e3c96c72e7b05b568104441f0f77 to your computer and use it in GitHub Desktop.
Save krainboltgreene/8203e3c96c72e7b05b568104441f0f77 to your computer and use it in GitHub Desktop.
def unload_cache_attempt({:ignore, :retry}, resource, parameters, http_client, cache) do
Logger.warn("Retrying request in 1s")
Process.sleep(1000)
fetch_for(resource, parameters, http_client, cache)
end
def unload_cache_attempt({:ok, %{status_code: 502}}, resource, parameters, http_client, cache) do
Logger.warn("Retrying request in 1s")
Process.sleep(1000)
fetch_for(resource, parameters, http_client, cache)
end
def unload_cache_attempt({:commit, value}, _resource, _parameters, _http_client, _cache) do
value
end
def unload_cache_attempt({:ok, value}, _resource, _parameters, _http_client, _cache) do
value
end
def unload_cache_attempt({:error, message}, _resource, _parameters, _http_client, _cache) do
Logger.error(message)
{:error, message}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment