Current section

9 Versions

Jump to

Compare versions

4 files changed
+39 additions
-4 deletions
  @@ -1,7 +1,13 @@
1 1 # Changelog for ConnGRPC
2 2
3 3
4 - ## v0.2.0
4 + ## v0.3.0
5 +
6 + ### Added
7 +
8 + - `otp_app` option on `ConnGRPC.Pool`
9 +
10 + ## v0.2.1
5 11
6 12 ### Fix
  @@ -1,6 +1,6 @@
1 1 {<<"links">>,[{<<"GitHub">>,<<"https://github.com/TheRealReal/conn_grpc">>}]}.
2 2 {<<"name">>,<<"conn_grpc">>}.
3 - {<<"version">>,<<"0.2.1">>}.
3 + {<<"version">>,<<"0.3.0">>}.
4 4 {<<"description">>,
5 5 <<"Persistent channels, and channel pools for gRPC Elixir">>}.
6 6 {<<"elixir">>,<<"~> 1.12">>}.
  @@ -21,6 +21,26 @@ defmodule ConnGRPC.Pool do
21 21 channel: [address: "localhost:50051", opts: []]
22 22 end
23 23
24 + You can also use the `:otp_app` option to load configuration from your application's config:
25 +
26 + defmodule DemoPool do
27 + use ConnGRPC.Pool, otp_app: :my_app
28 + end
29 +
30 + This will load configuration from `Application.get_env(:my_app, DemoPool, [])` and merge it
31 + with the options passed to `child_spec/1`.
32 +
33 + Then configure it in your `config/runtime.exs`:
34 +
35 + import Config
36 +
37 + config :my_app, DemoPool,
38 + pool_size: String.to_integer(System.get_env("GRPC_POOL_SIZE", "5")),
39 + channel: [
40 + address: System.fetch_env!("GRPC_ADDRESS"),
41 + opts: []
42 + ]
43 +
24 44 The format of `address` and `opts` is the same used by
25 45 [`GRPC.Stub.connect/2`](https://hexdocs.pm/grpc/0.5.0/GRPC.Stub.html#connect/2)
26 46
  @@ -99,8 +119,17 @@ defmodule ConnGRPC.Pool do
99 119 def get_all_pids, do: ConnGRPC.Pool.get_all_pids(__MODULE__)
100 120
101 121 def child_spec(opts) do
122 + {otp_app, use_opts} = Keyword.pop(unquote(use_opts), :otp_app)
123 +
124 + app_env_opts =
125 + case otp_app do
126 + nil -> []
127 + app -> Application.get_env(app, __MODULE__, [])
128 + end
129 +
102 130 [name: __MODULE__]
103 - |> Keyword.merge(unquote(use_opts))
131 + |> Keyword.merge(use_opts)
132 + |> Keyword.merge(app_env_opts)
104 133 |> Keyword.merge(opts)
105 134 |> ConnGRPC.Pool.child_spec()
106 135 |> Supervisor.child_spec(id: __MODULE__)
  @@ -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.2.1"
5 + @version "0.3.0"
6 6
7 7 def project do
8 8 [