25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-16 17:15:55 +01:00

Redis: Use the recommended eredis:start_link/1 function

This commit is contained in:
Badlop 2024-12-05 10:13:51 +01:00
parent 3ae636b454
commit a84c492130

View File

@ -483,14 +483,26 @@ connect(#state{num = Num}) ->
do_connect(1, Server, Port, Pass, _DB, _ConnTimeout) -> do_connect(1, Server, Port, Pass, _DB, _ConnTimeout) ->
%% First connection in the pool is always a subscriber %% First connection in the pool is always a subscriber
Res = eredis_sub:start_link(Server, Port, Pass, no_reconnect, infinity, drop), Options = [{host, Server},
{port, Port},
{password, Pass},
{reconnect_sleep, no_reconnect},
{max_queue_size, infinity},
{queue_behaviour, drop}],
Res = eredis_sub:start_link(Options),
case Res of case Res of
{ok, Pid} -> eredis_sub:controlling_process(Pid); {ok, Pid} -> eredis_sub:controlling_process(Pid);
_ -> ok _ -> ok
end, end,
Res; Res;
do_connect(_, Server, Port, Pass, DB, ConnTimeout) -> do_connect(_, Server, Port, Pass, DB, ConnTimeout) ->
eredis:start_link(Server, Port, DB, Pass, no_reconnect, ConnTimeout). Options = [{host, Server},
{port, Port},
{database, DB},
{password, Pass},
{reconnect_sleep, no_reconnect},
{connect_timeout, ConnTimeout}],
eredis:start_link(Options).
-spec call(pos_integer(), {q, redis_command()}, integer()) -> -spec call(pos_integer(), {q, redis_command()}, integer()) ->
{ok, redis_reply()} | redis_error(); {ok, redis_reply()} | redis_error();