mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-16 17:15:55 +01:00
Redis: Add support for unix domain socket (#4318)
This commit is contained in:
parent
a84c492130
commit
f269d5b613
@ -1137,11 +1137,13 @@ doc() ->
|
||||
"The default value is the value defined in _`queue_type`_ "
|
||||
"or 'ram' if the latter is not set.")}},
|
||||
{redis_server,
|
||||
#{value => ?T("Hostname"),
|
||||
#{value => "Host | IP Address | Unix Socket Path",
|
||||
note => "improved in 24.xx",
|
||||
desc =>
|
||||
?T("A hostname or an IP address of the "
|
||||
?T("A hostname, IP address or unix domain socket file of the "
|
||||
"_`database.md#redis|Redis`_ server. "
|
||||
"The default is 'localhost'.")}},
|
||||
"Setup the path to unix domain socket like: '\"unix:/path/to/socket\"'. "
|
||||
"The default value is 'localhost'.")}},
|
||||
{registration_timeout,
|
||||
#{value => "timeout()",
|
||||
desc =>
|
||||
@ -1434,7 +1436,7 @@ doc() ->
|
||||
?T("The hostname or IP address of the SQL server. For _`sql_type`_ "
|
||||
"'mssql' or 'odbc' this can also be an ODBC connection string. "
|
||||
"When _`sql_type`_ is 'mysql' or 'pgsql', this can be the path to "
|
||||
"a unix domain socket expressed like: \"unix:/path/to/socket\"."
|
||||
"a unix domain socket expressed like: '\"unix:/path/to/socket\"'."
|
||||
"The default value is 'localhost'.")}},
|
||||
{sql_ssl,
|
||||
#{value => "true | false",
|
||||
|
@ -457,11 +457,12 @@ code_change(_OldVsn, State, _Extra) ->
|
||||
%%%===================================================================
|
||||
-spec connect(state()) -> {ok, pid()} | {error, any()}.
|
||||
connect(#state{num = Num}) ->
|
||||
Server = ejabberd_option:redis_server(),
|
||||
Server1 = ejabberd_option:redis_server(),
|
||||
Port = ejabberd_option:redis_port(),
|
||||
DB = ejabberd_option:redis_db(),
|
||||
Pass = ejabberd_option:redis_password(),
|
||||
ConnTimeout = ejabberd_option:redis_connect_timeout(),
|
||||
Server = parse_server(Server1),
|
||||
try case do_connect(Num, Server, Port, Pass, DB, ConnTimeout) of
|
||||
{ok, Client} ->
|
||||
?DEBUG("Connection #~p established to Redis at ~ts:~p",
|
||||
@ -481,6 +482,11 @@ connect(#state{num = Num}) ->
|
||||
{error, Reason}
|
||||
end.
|
||||
|
||||
parse_server([$u,$n,$i,$x,$: | Path]) ->
|
||||
{local, Path};
|
||||
parse_server(Server) ->
|
||||
Server.
|
||||
|
||||
do_connect(1, Server, Port, Pass, _DB, _ConnTimeout) ->
|
||||
%% First connection in the pool is always a subscriber
|
||||
Options = [{host, Server},
|
||||
|
Loading…
Reference in New Issue
Block a user