Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
Rename :socket_file to :socket
Browse files Browse the repository at this point in the history
  • Loading branch information
José Valim committed Feb 7, 2018
1 parent dbd4172 commit 49ad706
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/postgrex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ defmodule Postgrex do
## Options
* `:hostname` - Server hostname (default: PGHOST env variable, then localhost);
* `:socket_dir` - Connect to Postgres via UNIX sockets in the given directory
(takes precedence over the hostname, preferred method for configuring sockets);
* `:socket_file` - Connect to Postgres via UNIX sockets using the given file
(takes precedence over the hostname and socket_dir);
* `:socket_dir` - Connect to Postgres via UNIX sockets in the given directory;
The socket name is derived based on the part. This is the preferred method
for configuring sockets and it takes precedence over the hostname. If you are
connecting to a socket outside of the Postgres convention, use `:socket` instead;
* `:socket` - Connect to Postgres via UNIX sockets in the given path.
This option takes precedence over the `:hostname` and `:socket_dir`;
* `:port` - Server port (default: PGPORT env variable, then 5432);
* `:database` - Database (default: PGDATABASE env variable; otherwise required);
* `:username` - Username (default: PGUSER env variable, then USER env var);
Expand Down
4 changes: 2 additions & 2 deletions lib/postgrex/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule Postgrex.Protocol do
port = opts[:port] || 5432

{host, port} =
case Keyword.fetch(opts, :socket_file) do
case Keyword.fetch(opts, :socket) do
{:ok, file} ->
{{:local, file}, 0}

Expand All @@ -70,7 +70,7 @@ defmodule Postgrex.Protocol do

:error ->
raise ArgumentError,
"expected :hostname, :socket_dir, or :socket_file to be given"
"expected :hostname, :socket_dir, or :socket to be given"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/login_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ defmodule LoginTest do
end

@tag :unix
test "socket_file precedes socket_dir", context do
test "socket precedes socket_dir", context do
Process.flag(:trap_exit, true)
opts = [socket_file: "/socketfile", socket_dir: "/socketdir"]
opts = [socket: "/socketfile", socket_dir: "/socketdir"]

capture_log fn ->
assert {:ok, pid} = P.start_link(opts ++ context[:options])
Expand Down

0 comments on commit 49ad706

Please sign in to comment.