Skip to content
Closed
Show file tree
Hide file tree
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
Next Next commit
fix: add in new >v0.18 ssl option configuration, add auto-reconnect f…
…or notifications
  • Loading branch information
Ziinc committed Apr 17, 2025
commit e497d540f74f4f34bbab5536b861a414ef5a6d49
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ config :libcluster,
port: 5432,
# optional, connection parameters. Defaults to []
parameters: [],
# optional, defaults to false
# optional, defaults to false. Refer to Postgrex docs
ssl: true,
# optional, please refer to the Postgrex docs
ssl_opts: nil,
# optional, please refer to the Postgrex docs
socket_options: nil,
# optional, defaults to node cookie
# must be a valid postgres identifier (alphanumeric and underscores only) with valid length
channel_name: "cluster",
# optional, heartbeat interval in ms. defaults to 5s
heartbeat_interval: 10_000
# optional, auto-reconnect to notifications, defaults to true
auto_reconnect: false
],
]
]
Expand Down
9 changes: 6 additions & 3 deletions lib/strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ defmodule LibclusterPostgres.Strategy do
def init([state]) do
channel_name = Keyword.get(state.config, :channel_name, clean_cookie(Node.get_cookie()))

ssl = if ssl_value = Keyword.get(state.config, :ssl) do
Keyword.get(state.config, :ssl_opts) || ssl_value
end
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),
ssl: ssl,
socket_options: Keyword.get(state.config, :socket_options, []),
parameters: Keyword.get(state.config, :parameters, []),
channel_name: channel_name
channel_name: channel_name,
auto_reconnect: Keyword.get(state.config, :auto_reconnect, true)
]

config =
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule LibclusterPostgres.MixProject do
[
name: "libcluster_postgres",
app: :libcluster_postgres,
version: "0.1.3",
version: "0.2.0",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand All @@ -27,7 +27,7 @@ defmodule LibclusterPostgres.MixProject do
defp deps do
[
{:libcluster, "~> 3.3"},
{:postgrex, ">= 0.0.0"},
{:postgrex, ">= 0.18.0"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
]
end
Expand Down