increase timeout for admin login

This commit is contained in:
Tao Bror Bojlén 2019-08-29 15:56:13 +01:00
parent 02dbab3d17
commit f95d2dd9e9
No known key found for this signature in database
GPG Key ID: C6EC7AAB905F9E6F
2 changed files with 11 additions and 6 deletions

View File

@ -161,13 +161,13 @@ defmodule Backend.Util do
@doc """
Gets and decodes a HTTP response.
"""
@spec get_and_decode(String.t()) ::
@spec get_and_decode(String.t(), Atom.t(), Integer.t()) ::
{:ok, any()} | {:error, Jason.DecodeError.t() | HTTPoison.Error.t()}
def get_and_decode(url) do
def get_and_decode(url, pool \\ :crawler, timeout \\ 15_000) do
case HTTPoison.get(url, [{"User-Agent", get_config(:user_agent)}],
hackney: [pool: :crawler],
recv_timeout: 15_000,
timeout: 15_000
hackney: [pool: pool],
recv_timeout: timeout,
timeout: timeout
) do
{:ok, %{status_code: 200, body: body}} -> Jason.decode(body)
{:ok, _} -> {:error, %HTTPoison.Error{reason: "Non-200 response"}}

View File

@ -38,7 +38,12 @@ defmodule BackendWeb.AdminLoginController do
def create(conn, %{"domain" => domain, "type" => type}) do
cleaned_domain = clean_domain(domain)
{data_state, instance_data} = get_and_decode("https://#{cleaned_domain}/api/v1/instance")
{data_state, instance_data} =
get_and_decode("https://#{cleaned_domain}/api/v1/instance",
pool: :admin_login,
timeout: 20_000
)
error =
cond do