summaryrefslogtreecommitdiff
path: root/src/ejabberd_redis.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-29 11:39:40 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-29 11:39:40 +0300
commitb82b93f8f0c229e94a89469b0754bab0e28cd17c (patch)
tree56f5c7a25aa19254b4f30b1cf33fc34dcbadcbb7 /src/ejabberd_redis.erl
parentDon't re-define validation functions in multiple places (diff)
Don't validate an option in ejabberd_config:get_option() functions
The commit introduces the following changes: * Now there is no need to pass validating function in ejabberd_config:get_option() functions, because the configuration keeps already validated values. * New function ejabberd_config:get_option/1 is introduced * Function ejabberd_config:get_option/3 is deprecated. If the function is still called, the second argument (validating function) is simply ignored. * The second argument for ejabberd_config:get_option/2 is now a default value, not a validating function.
Diffstat (limited to 'src/ejabberd_redis.erl')
-rw-r--r--src/ejabberd_redis.erl38
1 files changed, 8 insertions, 30 deletions
diff --git a/src/ejabberd_redis.erl b/src/ejabberd_redis.erl
index 7757c6df..56948ec8 100644
--- a/src/ejabberd_redis.erl
+++ b/src/ejabberd_redis.erl
@@ -421,26 +421,13 @@ code_change(_OldVsn, State, _Extra) ->
%%%===================================================================
-spec connect(state()) -> {ok, pid()} | {error, any()}.
connect(#state{num = Num}) ->
- Server = ejabberd_config:get_option(redis_server,
- fun iolist_to_list/1,
- "localhost"),
- Port = ejabberd_config:get_option(redis_port,
- fun(P) when is_integer(P),
- P>0, P<65536 ->
- P
- end, 6379),
- DB = ejabberd_config:get_option(redis_db,
- fun(I) when is_integer(I), I >= 0 ->
- I
- end, 0),
- Pass = ejabberd_config:get_option(redis_password,
- fun iolist_to_list/1,
- ""),
+ Server = ejabberd_config:get_option(redis_server, "localhost"),
+ Port = ejabberd_config:get_option(redis_port, 6379),
+ DB = ejabberd_config:get_option(redis_db, 0),
+ Pass = ejabberd_config:get_option(redis_password, ""),
ConnTimeout = timer:seconds(
ejabberd_config:get_option(
- redis_connect_timeout,
- fun(I) when is_integer(I), I>0 -> I end,
- 1)),
+ redis_connect_timeout, 1)),
try case do_connect(Num, Server, Port, Pass, DB, ConnTimeout) of
{ok, Client} ->
?DEBUG("Connection #~p established to Redis at ~s:~p",
@@ -552,10 +539,6 @@ reply(Val) ->
_ -> queued
end.
--spec iolist_to_list(iodata()) -> string().
-iolist_to_list(IOList) ->
- binary_to_list(iolist_to_binary(IOList)).
-
-spec max_fsm_queue() -> pos_integer().
max_fsm_queue() ->
proplists:get_value(max_queue, fsm_limit_opts(), ?DEFAULT_MAX_QUEUE).
@@ -564,14 +547,9 @@ fsm_limit_opts() ->
ejabberd_config:fsm_limit_opts([]).
get_queue_type() ->
- case ejabberd_config:get_option(
- redis_queue_type,
- ejabberd_redis_sup:opt_type(redis_queue_type)) of
- undefined ->
- ejabberd_config:default_queue_type(global);
- Type ->
- Type
- end.
+ ejabberd_config:get_option(
+ redis_queue_type,
+ ejabberd_config:default_queue_type(global)).
-spec flush_queue(p1_queue:queue()) -> p1_queue:queue().
flush_queue(Q) ->