From 8a63c7e193e967749196057fcacb88374e9beca5 Mon Sep 17 00:00:00 2001 From: Pulkit Goyal Date: Wed, 16 Apr 2025 11:49:23 +0530 Subject: [PATCH 1/2] Support socket options (#17) --- README.md | 2 ++ lib/strategy.ex | 1 + 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 51467e1..c1a2847 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ config :libcluster, 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 channel_name: "cluster" ], diff --git a/lib/strategy.ex b/lib/strategy.ex index 25d5dfc..3adb48c 100644 --- a/lib/strategy.ex +++ b/lib/strategy.ex @@ -34,6 +34,7 @@ defmodule LibclusterPostgres.Strategy do 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.fetch!(state.config, :parameters), channel_name: channel_name ] From 82e36ab33ec0d83c1f7ded57ac977f9ba1079654 Mon Sep 17 00:00:00 2001 From: Ziinc Date: Thu, 17 Apr 2025 14:39:37 +0800 Subject: [PATCH 2/2] docs: add documentation on channel identifier, closes #18 (#19) * docs: add documentation on chanenl_name identifier, closes #18 * docs: add :heartbeat_interval docs * chore: version bump * feat: make connection parameters optional --- README.md | 12 +++++++++--- lib/strategy.ex | 2 +- mix.exs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c1a2847..69e66d3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# libcluster Postgres Strategy +# Libcluster Postgres Strategy [![Hex version badge](https://img.shields.io/hexpm/v/libcluster_postgres.svg)](https://hex.pm/packages/libcluster_postgres) [![License badge](https://img.shields.io/hexpm/l/libcluster_postgres.svg)](https://github.com/supabase/libcluster_postgres/blob/main/LICENSE) @@ -18,7 +18,9 @@ by adding `libcluster_postgres` to your list of dependencies in `mix.exs`: ```elixir def deps do - [{:libcluster_postgres, "~> 0.1"}] + [ + {:libcluster_postgres, "~> 0.1"} + ] end ``` @@ -37,6 +39,7 @@ config :libcluster, password: "postgres", database: "postgres", port: 5432, + # optional, connection parameters. Defaults to [] parameters: [], # optional, defaults to false ssl: true, @@ -45,7 +48,10 @@ config :libcluster, # optional, please refer to the Postgrex docs socket_options: nil, # optional, defaults to node cookie - channel_name: "cluster" + # 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 ], ] ] diff --git a/lib/strategy.ex b/lib/strategy.ex index 3adb48c..bff79e5 100644 --- a/lib/strategy.ex +++ b/lib/strategy.ex @@ -35,7 +35,7 @@ defmodule LibclusterPostgres.Strategy do ssl: Keyword.get(state.config, :ssl), ssl_opts: Keyword.get(state.config, :ssl_opts), socket_options: Keyword.get(state.config, :socket_options, []), - parameters: Keyword.fetch!(state.config, :parameters), + parameters: Keyword.get(state.config, :parameters, []), channel_name: channel_name ] diff --git a/mix.exs b/mix.exs index 5f29689..be837f2 100644 --- a/mix.exs +++ b/mix.exs @@ -5,7 +5,7 @@ defmodule LibclusterPostgres.MixProject do [ name: "libcluster_postgres", app: :libcluster_postgres, - version: "0.1.2", + version: "0.1.3", elixir: "~> 1.14", start_permanent: Mix.env() == :prod, deps: deps(),