diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2015-04-10 16:53:53 +0300 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-04-10 17:35:32 +0200 |
| commit | 78efd9024dc5fda41f852c585f15bf43dd3ea55b (patch) | |
| tree | b99dbe0f7b794e549f058cdc08160e2839ac4dc3 /src | |
| parent | 5aba7d2a60f1668bde337ab2452a53ce8e597325 (diff) | |
| download | rabbitmq-server-git-78efd9024dc5fda41f852c585f15bf43dd3ea55b.tar.gz | |
Add rabbit_misc:get_env/3
This is the same as application:get_env/3, but this one was only added
to Erlang R16.
References rabbitmq/rabbitmq-management#33.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_misc.erl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 5e9c7ceb40..8f9704c480 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -72,6 +72,7 @@ -export([store_proc_name/1, store_proc_name/2]). -export([moving_average/4]). -export([now_to_ms/1]). +-export([get_env/3]). %% Horrible macro to use in guards -define(IS_BENIGN_EXIT(R), @@ -261,6 +262,7 @@ -spec(now_to_ms/1 :: ({non_neg_integer(), non_neg_integer(), non_neg_integer()}) -> pos_integer()). +-spec(get_env/3 :: (atom(), atom(), term()) -> term()). -endif. %%---------------------------------------------------------------------------- @@ -1096,6 +1098,13 @@ cancel_timer({timer, Ref}) -> {ok, cancel} = timer:cancel(Ref), store_proc_name(Type, ProcName) -> store_proc_name({Type, ProcName}). store_proc_name(TypeProcName) -> put(process_name, TypeProcName). +%% application:get_env/3 is only available in R16B01 or later. +get_env(Application, Key, Def) -> + case application:get_env(Application, Key) of + {ok, Val} -> Val; + undefined -> Def + end. + moving_average(_Time, _HalfLife, Next, undefined) -> Next; %% We want the Weight to decrease as Time goes up (since Weight is the |
