mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Remove duplicated code
This commit is contained in:
parent
6987e85602
commit
60fe008268
@ -209,6 +209,13 @@ get_opt_host(Host, Opts, Default) ->
|
|||||||
Val = get_opt(host, Opts, fun iolist_to_binary/1, Default),
|
Val = get_opt(host, Opts, fun iolist_to_binary/1, Default),
|
||||||
ejabberd_regexp:greplace(Val, <<"@HOST@">>, Host).
|
ejabberd_regexp:greplace(Val, <<"@HOST@">>, Host).
|
||||||
|
|
||||||
|
-spec v_db(odbc | mnesia | riak | internal) -> odbc | mnesia | riak.
|
||||||
|
|
||||||
|
v_db(odbc) -> odbc;
|
||||||
|
v_db(internal) -> mnesia;
|
||||||
|
v_db(mnesia) -> mnesia;
|
||||||
|
v_db(riak) -> riak.
|
||||||
|
|
||||||
-spec db_type(opts()) -> odbc | mnesia | riak.
|
-spec db_type(opts()) -> odbc | mnesia | riak.
|
||||||
|
|
||||||
db_type(Opts) ->
|
db_type(Opts) ->
|
||||||
@ -217,31 +224,14 @@ db_type(Opts) ->
|
|||||||
-spec db_type(binary() | global, atom() | opts()) -> odbc | mnesia | riak.
|
-spec db_type(binary() | global, atom() | opts()) -> odbc | mnesia | riak.
|
||||||
|
|
||||||
db_type(Host, Module) when is_atom(Module) ->
|
db_type(Host, Module) when is_atom(Module) ->
|
||||||
get_module_opt(Host, Module, db_type,
|
get_module_opt(Host, Module, db_type, fun v_db/1, default_db(Host));
|
||||||
fun(odbc) -> odbc;
|
|
||||||
(internal) -> mnesia;
|
|
||||||
(mnesia) -> mnesia;
|
|
||||||
(riak) -> riak
|
|
||||||
end,
|
|
||||||
default_db(Host));
|
|
||||||
db_type(Host, Opts) when is_list(Opts) ->
|
db_type(Host, Opts) when is_list(Opts) ->
|
||||||
get_opt(db_type, Opts,
|
get_opt(db_type, Opts, fun v_db/1, default_db(Host)).
|
||||||
fun(odbc) -> odbc;
|
|
||||||
(internal) -> mnesia;
|
|
||||||
(mnesia) -> mnesia;
|
|
||||||
(riak) -> riak
|
|
||||||
end,
|
|
||||||
default_db(Host)).
|
|
||||||
|
|
||||||
-spec default_db(binary() | global) -> odbc | mnesia | riak.
|
-spec default_db(binary() | global) -> odbc | mnesia | riak.
|
||||||
|
|
||||||
default_db(Host) ->
|
default_db(Host) ->
|
||||||
ejabberd_config:get_option({default_db, Host},
|
ejabberd_config:get_option({default_db, Host}, fun v_db/1, mnesia).
|
||||||
fun(odbc) -> odbc;
|
|
||||||
(mnesia) -> mnesia;
|
|
||||||
(riak) -> riak;
|
|
||||||
(internal) -> mnesia
|
|
||||||
end, mnesia).
|
|
||||||
|
|
||||||
-spec loaded_modules(binary()) -> [atom()].
|
-spec loaded_modules(binary()) -> [atom()].
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user