Skip to content

Commit d54f8f5

Browse files
josevalimtapickell
andauthored
Assume PG default values (#21)
* Assume PG default port * Prove port is optional * Use Keyword.take * Update lib/strategy.ex Co-authored-by: Todd Pickell <[email protected]> --------- Co-authored-by: Todd Pickell <[email protected]>
1 parent d8efde7 commit d54f8f5

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

lib/strategy.ex

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ defmodule LibclusterPostgres.Strategy do
1818
alias Cluster.Strategy
1919
alias Cluster.Logger
2020

21+
@postgrex_keys [:hostname, :username, :password, :database, :port] ++
22+
[:ssl, :ssl_opts, :socket, :socket_dir, :socket_options, :parameters]
23+
2124
def start_link(args), do: GenServer.start_link(__MODULE__, args)
2225

2326
@spec init([%{:config => any(), :meta => any(), optional(any()) => any()}, ...]) ::
@@ -26,18 +29,9 @@ defmodule LibclusterPostgres.Strategy do
2629
def init([state]) do
2730
channel_name = Keyword.get(state.config, :channel_name, clean_cookie(Node.get_cookie()))
2831

29-
opts = [
30-
hostname: Keyword.fetch!(state.config, :hostname),
31-
username: Keyword.fetch!(state.config, :username),
32-
password: Keyword.fetch!(state.config, :password),
33-
database: Keyword.fetch!(state.config, :database),
34-
port: Keyword.fetch!(state.config, :port),
35-
ssl: Keyword.get(state.config, :ssl),
36-
ssl_opts: Keyword.get(state.config, :ssl_opts),
37-
socket_options: Keyword.get(state.config, :socket_options, []),
38-
parameters: Keyword.get(state.config, :parameters, []),
39-
channel_name: channel_name
40-
]
32+
opts =
33+
[channel_name: channel_name] ++
34+
Keyword.take(state.config, @postgrex_keys)
4135

4236
config =
4337
state.config

test/strategy_test.exs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ defmodule LibclusterPostgres.StrategyTest do
88
username: "postgres",
99
password: "postgres",
1010
database: "postgres",
11-
port: 5432,
12-
parameters: [],
1311
channel_name: "cluster"
1412
]
1513

0 commit comments

Comments
 (0)