aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkballou <kballou@devnulllabs.io>2016-03-25 15:52:55 -0600
committerkballou <kballou@devnulllabs.io>2016-03-25 16:27:34 -0600
commit09977eccf07d6c75c0fcf933c02c009b0afa8541 (patch)
tree2e292f97f8d12fab17e9e66fb06cdf3dc2d99f77
parent43e753753f01bd741c605e442ec34b81af7b33c5 (diff)
downloadex_prometheus_io-09977eccf07d6c75c0fcf933c02c009b0afa8541.tar.gz
ex_prometheus_io-09977eccf07d6c75c0fcf933c02c009b0afa8541.tar.xz
Refactor `Query` to use a pluggable http library
* Refactor `lib/ex_prometheus_io/query.ex` use a pluggable client module * Add stub environment configs, setup `test.exs` to use a test support module
-rw-r--r--config/config.exs2
-rw-r--r--config/dev.exs1
-rw-r--r--config/prod.exs1
-rw-r--r--config/test.exs3
-rw-r--r--lib/ex_prometheus_io/query.ex3
5 files changed, 9 insertions, 1 deletions
diff --git a/config/config.exs b/config/config.exs
index eecc967..f3049ea 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -1,3 +1,5 @@
use Mix.Config
config :ex_prometheus_io, hostname: "prometheus:9090"
+
+import_config "#{Mix.env}.exs"
diff --git a/config/dev.exs b/config/dev.exs
new file mode 100644
index 0000000..d2d855e
--- /dev/null
+++ b/config/dev.exs
@@ -0,0 +1 @@
+use Mix.Config
diff --git a/config/prod.exs b/config/prod.exs
new file mode 100644
index 0000000..d2d855e
--- /dev/null
+++ b/config/prod.exs
@@ -0,0 +1 @@
+use Mix.Config
diff --git a/config/test.exs b/config/test.exs
new file mode 100644
index 0000000..b43419c
--- /dev/null
+++ b/config/test.exs
@@ -0,0 +1,3 @@
+use Mix.Config
+
+config :ex_prometheus_io, http_client: ExPrometheusIo.Test.HTTPClient
diff --git a/lib/ex_prometheus_io/query.ex b/lib/ex_prometheus_io/query.ex
index 20b01a9..0c346b5 100644
--- a/lib/ex_prometheus_io/query.ex
+++ b/lib/ex_prometheus_io/query.ex
@@ -7,8 +7,9 @@ defmodule ExPrometheusIo.Query do
|> send_results(query_ref, owner)
end
+ @http Application.get_env(:ex_prometheus_io, :http_client) || :httpc
defp fetch_json(uri) do
- {:ok, {_, _, body}} = :httpc.request(uri |> String.to_char_list())
+ {:ok, {_, _, body}} = @http.request(uri |> String.to_char_list())
body
end