Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions lib/strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ defmodule LibclusterPostgres.Strategy do
alias Cluster.Strategy
alias Cluster.Logger

@postgrex_keys [:hostname, :username, :password, :database, :port] ++
[:ssl, :ssl_opts, :socket, :socket_dir, :socket_options, :parameters]

def start_link(args), do: GenServer.start_link(__MODULE__, args)

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

opts = [
hostname: Keyword.fetch!(state.config, :hostname),
username: Keyword.fetch!(state.config, :username),
password: Keyword.fetch!(state.config, :password),
database: Keyword.fetch!(state.config, :database),
port: Keyword.fetch!(state.config, :port),
ssl: Keyword.get(state.config, :ssl),
ssl_opts: Keyword.get(state.config, :ssl_opts),
socket_options: Keyword.get(state.config, :socket_options, []),
parameters: Keyword.get(state.config, :parameters, []),
channel_name: channel_name
]
opts =
[channel_name: channel_name] ++
Keyword.take(state.config, @postgrex_keys)

config =
state.config
Expand Down
2 changes: 0 additions & 2 deletions test/strategy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ defmodule LibclusterPostgres.StrategyTest do
username: "postgres",
password: "postgres",
database: "postgres",
port: 5432,
parameters: [],
channel_name: "cluster"
]

Expand Down