From c9e878169bd53d7f06e1086a1f81a89a65f60e5d Mon Sep 17 00:00:00 2001 From: Joshua Fleck Date: Sat, 21 Jan 2017 13:23:04 +0000 Subject: [PATCH] Make amount of sleep between attempts configurable --- README.md | 2 ++ lib/settings.ex | 2 +- mix.exs | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21aa2ef..9d73469 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ config :ex_ngrok, port: "4000", # The URL of Ngrok's API (used to retrieve its settings) api_url: "http://localhost:4040/api/tunnels", + # The amount of sleep (in ms) to put between attempts to connect to Ngrok + sleep_between_attempts: 200, # Any other tunneling options that will be passed directly to Ngrok options: "" ``` diff --git a/lib/settings.ex b/lib/settings.ex index e9bb191..3a103d0 100644 --- a/lib/settings.ex +++ b/lib/settings.ex @@ -35,7 +35,7 @@ defmodule Ngrok.Settings do defp tunnel_settings(), do: tunnel_settings(0, "") defp tunnel_settings(6, error_message), do: raise "Unable to retrieve setting from Ngrok: #{error_message}" defp tunnel_settings(total_attempts, _) do - :timer.sleep(total_attempts * 100) + :timer.sleep(total_attempts * Application.get_env(:ex_ngrok, :sleep_between_attempts)) case Ngrok.Api.tunnel_settings do {:ok, settings} -> settings diff --git a/mix.exs b/mix.exs index b941f6e..106e0dc 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule Ngrok.Mixfile do def project do [app: :ex_ngrok, - version: "0.3.1", + version: "0.3.2", elixir: "~> 1.3", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, @@ -20,6 +20,7 @@ defmodule Ngrok.Mixfile do executable: "ngrok", protocol: "http", port: "4000", + sleep_between_attempts: 200, options: "", ], mod: {Ngrok, []}]