Current section
9 Versions
Jump to
Current section
9 Versions
Compare versions
4
files changed
+26
additions
-4
deletions
| @@ -1,6 +1,12 @@ | |
| 1 1 | # Changelog for ConnGRPC |
| 2 2 | |
| 3 3 | |
| 4 | + ## v0.4.1 |
| 5 | + |
| 6 | + ### Fix |
| 7 | + |
| 8 | + - Fix pool overwriting user `on_connect`/`on_disconnect` callbacks, by @yordis (closes https://github.com/TheRealReal/conn_grpc/issues/22) |
| 9 | + |
| 4 10 | ## v0.4.0 |
| 5 11 | |
| 6 12 | ### Added |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/TheRealReal/conn_grpc">>}]}. |
| 2 2 | {<<"name">>,<<"conn_grpc">>}. |
| 3 | - {<<"version">>,<<"0.4.0">>}. |
| 3 | + {<<"version">>,<<"0.4.1">>}. |
| 4 4 | {<<"description">>, |
| 5 5 | <<"Persistent channels, and channel pools for gRPC Elixir">>}. |
| 6 6 | {<<"elixir">>,<<"~> 1.12">>}. |
| @@ -242,10 +242,13 @@ defmodule ConnGRPC.Pool do | |
| 242 242 | end |
| 243 243 | |
| 244 244 | defp build_channels_supervisor_spec(pool_name, pool_size, channel_opts, registry_name) do |
| 245 | + user_on_connect = Keyword.get(channel_opts, :on_connect) |
| 246 | + user_on_disconnect = Keyword.get(channel_opts, :on_disconnect) |
| 247 | + |
| 245 248 | channel_opts = |
| 246 249 | channel_opts |
| 247 | - |> Keyword.put(:on_connect, fn -> Registry.register(registry_name, :channels, nil) end) |
| 248 | - |> Keyword.put(:on_disconnect, fn -> Registry.unregister(registry_name, :channels) end) |
| 250 | + |> Keyword.put(:on_connect, fn -> on_connect(registry_name, user_on_connect) end) |
| 251 | + |> Keyword.put(:on_disconnect, fn -> on_disconnect(registry_name, user_on_disconnect) end) |
| 249 252 | |> Keyword.put(:pool_name, pool_name) |
| 250 253 | |
| 251 254 | channels_specs = |
| @@ -260,6 +263,19 @@ defmodule ConnGRPC.Pool do | |
| 260 263 | } |
| 261 264 | end |
| 262 265 | |
| 266 | + defp on_connect(registry_name, user_fn) do |
| 267 | + Registry.register(registry_name, :channels, nil) |
| 268 | + maybe_call(user_fn) |
| 269 | + end |
| 270 | + |
| 271 | + defp on_disconnect(registry_name, user_fn) do |
| 272 | + Registry.unregister(registry_name, :channels) |
| 273 | + maybe_call(user_fn) |
| 274 | + end |
| 275 | + |
| 276 | + defp maybe_call(nil), do: :ok |
| 277 | + defp maybe_call(fun), do: fun.() |
| 278 | + |
| 263 279 | defp build_ets_table(pool_name) do |
| 264 280 | ets_table = ets_table(pool_name) |
| @@ -2,7 +2,7 @@ defmodule ConnGRPC.MixProject do | |
| 2 2 | use Mix.Project |
| 3 3 | |
| 4 4 | @source_url "https://github.com/TheRealReal/conn_grpc" |
| 5 | - @version "0.4.0" |
| 5 | + @version "0.4.1" |
| 6 6 | |
| 7 7 | def project do |
| 8 8 | [ |