Current section
9 Versions
Jump to
Current section
9 Versions
Compare versions
4
files changed
+33
additions
-17
deletions
| @@ -1,11 +1,17 @@ | |
| 1 1 | # Changelog for ConnGRPC |
| 2 2 | |
| 3 3 | |
| 4 | + ## v0.4.2 |
| 5 | + |
| 6 | + ### Fix |
| 7 | + |
| 8 | + - Prevent exception when pool is not started, return error tuple instead, by @guisehn |
| 9 | + |
| 4 10 | ## v0.4.1 |
| 5 11 | |
| 6 12 | ### Fix |
| 7 13 | |
| 8 | - - Fix pool overwriting user `on_connect`/`on_disconnect` callbacks, by @yordis (closes https://github.com/TheRealReal/conn_grpc/issues/22) |
| 14 | + - Fix pool overwriting user `on_connect`/`on_disconnect` callbacks, by @yordis |
| 9 15 | |
| 10 16 | ## v0.4.0 |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/TheRealReal/conn_grpc">>}]}. |
| 2 2 | {<<"name">>,<<"conn_grpc">>}. |
| 3 | - {<<"version">>,<<"0.4.1">>}. |
| 3 | + {<<"version">>,<<"0.4.2">>}. |
| 4 4 | {<<"description">>, |
| 5 5 | <<"Persistent channels, and channel pools for gRPC Elixir">>}. |
| 6 6 | {<<"elixir">>,<<"~> 1.12">>}. |
| @@ -166,23 +166,33 @@ defmodule ConnGRPC.Pool do | |
| 166 166 | @spec get_channel(module | atom) :: {:ok, GRPC.Channel.t()} | {:error, :not_connected} |
| 167 167 | def get_channel(pool_name) do |
| 168 168 | start = System.monotonic_time() |
| 169 | - channels = Registry.lookup(registry(pool_name), :channels) |
| 170 | - pool_size = length(channels) |
| 171 169 | |
| 172 | - result = |
| 173 | - if pool_size > 0 do |
| 174 | - do_get_channel(pool_name, channels, pool_size) |
| 175 | - else |
| 176 | - {:error, :not_connected} |
| 177 | - end |
| 170 | + if registry_alive?(pool_name) do |
| 171 | + channels = Registry.lookup(registry(pool_name), :channels) |
| 172 | + pool_size = length(channels) |
| 178 173 | |
| 179 | - :telemetry.execute( |
| 180 | - [:conn_grpc, :pool, :get_channel], |
| 181 | - %{duration: System.monotonic_time() - start}, |
| 182 | - %{pool_name: pool_name} |
| 183 | - ) |
| 174 | + result = |
| 175 | + if pool_size > 0 do |
| 176 | + do_get_channel(pool_name, channels, pool_size) |
| 177 | + else |
| 178 | + {:error, :not_connected} |
| 179 | + end |
| 184 180 | |
| 185 | - result |
| 181 | + :telemetry.execute( |
| 182 | + [:conn_grpc, :pool, :get_channel], |
| 183 | + %{duration: System.monotonic_time() - start}, |
| 184 | + %{pool_name: pool_name} |
| 185 | + ) |
| 186 | + |
| 187 | + result |
| 188 | + else |
| 189 | + {:error, :not_started} |
| 190 | + end |
| 191 | + end |
| 192 | + |
| 193 | + defp registry_alive?(pool_name) do |
| 194 | + registry_name = registry(pool_name) |
| 195 | + Process.whereis(registry_name) != nil |
| 186 196 | end |
| 187 197 | |
| 188 198 | @doc "Returns a gRPC channel from the pool, raising on error" |
| @@ -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.1" |
| 5 | + @version "0.4.2" |
| 6 6 | |
| 7 7 | def project do |
| 8 8 | [ |