summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLindolfo 'Lorn' Rodrigues <lorn@lornlab.org>2020-03-17 19:30:34 -0300
committerLindolfo 'Lorn' Rodrigues <lorn@lornlab.org>2020-03-19 23:29:50 -0300
commit6589586f985b466194a6553c50ab3f7419a13b7f (patch)
treecdb94939b65877c420abd60a26f3eab595b9aae6 /lib
parentMerge pull request #14 from locaweb/fix-docs (diff)
Timeout option
Now, you need to pass the timeout for the PowerDNS API in seconds We need to add the timeout to the GenServer.call function
Diffstat (limited to 'lib')
-rw-r--r--lib/powerdnsex.ex2
-rw-r--r--lib/powerdnsex/config.ex5
-rw-r--r--lib/powerdnsex/http_client.ex6
3 files changed, 11 insertions, 2 deletions
diff --git a/lib/powerdnsex.ex b/lib/powerdnsex.ex
index 6568319..86628b7 100644
--- a/lib/powerdnsex.ex
+++ b/lib/powerdnsex.ex
@@ -98,5 +98,5 @@ defmodule PowerDNSex do
# Private #
###########
- defp call(params), do: GenServer.call(@name, params)
+ defp call(params), do: GenServer.call(@name, params, Config.powerdns_timeout)
end
diff --git a/lib/powerdnsex/config.ex b/lib/powerdnsex/config.ex
index 34d5889..1302524 100644
--- a/lib/powerdnsex/config.ex
+++ b/lib/powerdnsex/config.ex
@@ -1,6 +1,7 @@
defmodule PowerDNSex.Config do
defstruct url: "",
- token: ""
+ token: "",
+ timeout: "60"
alias PowerDNSex.Config
@@ -20,6 +21,8 @@ defmodule PowerDNSex.Config do
def powerdns_token, do: data().token
+ def powerdns_timeout, do: :timer.seconds(data().timeout)
+
def valid?(), do: powerdns_url() && powerdns_token()
###
diff --git a/lib/powerdnsex/http_client.ex b/lib/powerdnsex/http_client.ex
index 13e5023..3431795 100644
--- a/lib/powerdnsex/http_client.ex
+++ b/lib/powerdnsex/http_client.ex
@@ -13,4 +13,10 @@ defmodule PowerDNSex.HttpClient do
custom = ["X-API-Key": Config.powerdns_token()]
Keyword.merge(headers, custom)
end
+
+ def process_request_options(options) do
+ custom_options = [ssl: [{:versions, [:'tlsv1.1']}], recv_timeout: Config.powerdns_timeout()]
+ Keyword.merge(options, custom_options)
+ end
+
end