Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use Keyword.take
  • Loading branch information
josevalim committed Apr 22, 2025
commit 0a24e98a6d3d466f2a6de94124bc01d9f272b2bc
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_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.get(state.config, :port, 5432),
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