Skip to content

Commit

Permalink
Reduce delay
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshaughnessy committed Mar 1, 2023
1 parent b813728 commit 4b49215
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/ret/media_resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ defmodule Ret.MediaResolver do
%HTTPoison.Response{body: body} ->
{:error, body}

:timeout ->
{:error, "Failed to resolve via youtube-dl: timeout"}

:error ->
{:error, "Failed to resolve via youtube-dl"}
end
Expand Down Expand Up @@ -590,7 +593,7 @@ defmodule Ret.MediaResolver do
#
# https://youtube-dl-api-server.readthedocs.io/en/latest/api.html#api-methods
defp retry_get_until_valid_ytdl_response(url) do
retry with: exponential_backoff() |> randomize |> cap(1_000) |> expiry(10_000) do
retry with: constant_backoff(1_000) |> randomize() |> expiry(3_500) do
Statix.increment("ret.media_resolver.ytdl.requests")

case HTTPoison.get(url) do
Expand All @@ -599,6 +602,11 @@ defmodule Ret.MediaResolver do
Statix.increment("ret.media_resolver.ytdl.ok")
resp

{:error, %HTTPoison.Error{reason: :timeout, id: _}} ->
Statix.increment("ret.media_resolver.ytdl.errors")
# Return a different atom so that we do not retry
:timeout

_ ->
Statix.increment("ret.media_resolver.ytdl.errors")
:error
Expand Down

0 comments on commit 4b49215

Please sign in to comment.