2.0 - gen_conf:value/2 to read config

This commit is contained in:
Feng Lee 2016-07-21 17:19:08 +08:00
parent 2370e7dfcb
commit 1602b44267
1 changed files with 13 additions and 6 deletions

View File

@ -20,7 +20,7 @@
-include("emqttd_protocol.hrl").
-export([start/0, env/1, env/2, is_running/1]).
-export([start/0, conf/1, conf/2, env/1, env/2, is_running/1]).
%% PubSub API
-export([create/2, lookup/2, publish/1, subscribe/1, subscribe/3,
@ -39,13 +39,20 @@
-spec(start() -> ok | {error, any()}).
start() -> application:start(?APP).
%% @doc Group environment
-spec(env(Group :: atom()) -> list()).
env(Group) -> application:get_env(?APP, Group, []).
%% @doc Get Config
-spec(conf(Key :: atom()) -> any()).
conf(Key) -> gen_conf:value(?APP, Key).
-spec(conf(Key :: atom(), Default :: any()) -> any()).
conf(Key, Default) -> gen_conf:value(?APP, Key, Default).
%% @doc Environment
-spec(env(Key:: atom()) -> any()).
env(Key) -> application:get_env(?APP, Key).
%% @doc Get environment
-spec(env(Group :: atom(), Name :: atom()) -> undefined | any()).
env(Group, Name) -> proplists:get_value(Name, env(Group)).
-spec(env(Key:: atom(), Default:: any()) -> undefined | any()).
env(Key, Default) -> application:get_env(?APP, Key, Default).
%% @doc Is running?
-spec(is_running(node()) -> boolean()).