From c2ef4bb102d0cf41774eb99d5a2b42305a2a6851 Mon Sep 17 00:00:00 2001 From: Ariel Otilibili Date: Wed, 27 Dec 2023 06:42:07 +0100 Subject: [PATCH] Added Timeout to get_host As well, implemented get_host/4. --- src/erlazure.erl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/erlazure.erl b/src/erlazure.erl index 8f10e0d..f19160f 100644 --- a/src/erlazure.erl +++ b/src/erlazure.erl @@ -76,7 +76,7 @@ -export([list_tables/1, list_tables/3, new_table/2, delete_table/2]). %% Host API --export([get_host/3]). +-export([get_host/3, get_host/4]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -809,9 +809,17 @@ build_uri_base(Service, Account) -> get_host(Service, Account) -> lists:concat([Account, ".", erlang:atom_to_list(Service), ".core.windows.net"]). get_host(Pid, Service, []) -> - gen_server:call(Pid, {get_host, Service, ".core.windows.net"}); -get_host(Pid, Service, Domain) -> - gen_server:call(Pid, {get_host, Service, Domain}). + Domain = ".core.windows.net", + Timeout = ?gen_server_call_default_timeout, + get_host(Pid, Service, Domain, Timeout); +get_host(Pid, Service, Timeout) when is_integer(Timeout) -> + Domain = ".core.windows.net", + get_host(Pid, Service, Domain, Timeout); +get_host(Pid, Service, Domain) when is_list(Domain) -> + Timeout = ?gen_server_call_default_timeout, + get_host(Pid, Service, Domain, Timeout). +get_host(Pid, Service, Domain, Timeout) when is_list(Domain), is_integer(Timeout) -> + gen_server:call(Pid, {get_host, Service, Domain}, Timeout). -spec canonicalize_headers([string()]) -> string(). canonicalize_headers(Headers) ->