Skip to content

Commit 86736ae

Browse files
sleipnirAdriano Santos
andauthored
Fix/start server keyword (#422)
* chore: release new version * fix: passing adapter_opts along the way * chore: better validation message * chore: update version --------- Co-authored-by: Adriano Santos <[email protected]>
1 parent 78b8386 commit 86736ae

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/grpc/server/supervisor.ex

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule GRPC.Server.Supervisor do
1010
1111
def start(_type, _args) do
1212
children = [
13-
{GRPC.Server.Supervisor, endpoint: Your.Endpoint, port: 50051, start_server: true, ...}]
13+
{GRPC.Server.Supervisor, endpoint: Your.Endpoint, port: 50051, start_server: true, adapter_opts: [ip: {0, 0, 0, 0}], ...}]
1414
1515
Supervisor.start_link(children, strategy: :one_for_one, name: __MODULE__)
1616
end
@@ -41,6 +41,7 @@ defmodule GRPC.Server.Supervisor do
4141
* `:endpoint` - defines the endpoint module that will be started.
4242
* `:port` - the HTTP port for the endpoint.
4343
* `:servers` - the list of servers that will be be started.
44+
* `:adapter_opts` - options for the adapter.
4445
4546
Either `:endpoint` or `:servers` must be present, but not both.
4647
"""
@@ -60,7 +61,15 @@ defmodule GRPC.Server.Supervisor do
6061
through the :start_server option for the GRPC.Server.Supervisor"
6162
end
6263

63-
opts = Keyword.validate!(opts, [:endpoint, :servers, :start_server, :port])
64+
opts =
65+
case Keyword.validate(opts, [:endpoint, :servers, :start_server, :port, :adapter_opts]) do
66+
{:ok, _opts} ->
67+
opts
68+
69+
{:error, _} ->
70+
raise ArgumentError,
71+
"just [:endpoint, :servers, :start_server, :port,] are accepted as arguments, and any other keys for adapters should be passed as adapter_opts!"
72+
end
6473

6574
endpoint_or_servers =
6675
case {opts[:endpoint], opts[:servers]} do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule GRPC.Mixfile do
22
use Mix.Project
33

4-
@version "0.10.0"
4+
@version "0.10.2"
55

66
def project do
77
[

0 commit comments

Comments
 (0)