diff --git a/interop/mix.lock b/interop/mix.lock index 1a52d838..11f40443 100644 --- a/interop/mix.lock +++ b/interop/mix.lock @@ -6,7 +6,7 @@ "grpc": {:git, "https://github.com/elixir-grpc/grpc.git", "21422839798e49bf6d29327fab0a7add51becedd", []}, "grpc_prometheus": {:hex, :grpc_prometheus, "0.1.0", "a2f45ca83018c4ae59e4c293b7455634ac09e38c36cba7cc1fb8affdf462a6d5", [:mix], [{:grpc, ">= 0.0.0", [hex: :grpc, repo: "hexpm", optional: true]}, {:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm", "8b9ab3098657e7daec0b3edc78e1d02418bc0871618d8ca89b51b74a8086bb71"}, "grpc_statsd": {:hex, :grpc_statsd, "0.1.0", "a95ae388188486043f92a3c5091c143f5a646d6af80c9da5ee616546c4d8f5ff", [:mix], [{:grpc, ">= 0.0.0", [hex: :grpc, repo: "hexpm", optional: true]}, {:statix, ">= 0.0.0", [hex: :statix, repo: "hexpm", optional: true]}], "hexpm", "de0c05db313c7b3ffeff345855d173fd82fec3de16591a126b673f7f698d9e74"}, - "gun": {:hex, :gun, "2.0.0-rc.2", "7c489a32dedccb77b6e82d1f3c5a7dadfbfa004ec14e322cdb5e579c438632d2", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "6b9d1eae146410d727140dbf8b404b9631302ecc2066d1d12f22097ad7d254fc"}, + "gun": {:hex, :grpc_gun, "2.0.1", "221b792df3a93e8fead96f697cbaf920120deacced85c6cd3329d2e67f0871f8", [:rebar3], [{:cowlib, "~> 2.11", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "795a65eb9d0ba16697e6b0e1886009ce024799e43bb42753f0c59b029f592831"}, "prometheus": {:hex, :prometheus, "4.2.2", "a830e77b79dc6d28183f4db050a7cac926a6c58f1872f9ef94a35cd989aceef8", [:mix, :rebar3], [], "hexpm", "b479a33d4aa4ba7909186e29bb6c1240254e0047a8e2a9f88463f50c0089370e"}, "prometheus_ex": {:hex, :prometheus_ex, "3.0.5", "fa58cfd983487fc5ead331e9a3e0aa622c67232b3ec71710ced122c4c453a02f", [:mix], [{:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm", "9fd13404a48437e044b288b41f76e64acd9735fb8b0e3809f494811dfa66d0fb"}, "prometheus_httpd": {:hex, :prometheus_httpd, "2.1.11", "f616ed9b85b536b195d94104063025a91f904a4cfc20255363f49a197d96c896", [:rebar3], [{:accept, "~> 0.3", [hex: :accept, repo: "hexpm", optional: false]}, {:prometheus, "~> 4.2", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm", "0bbe831452cfdf9588538eb2f570b26f30c348adae5e95a7d87f35a5910bcf92"}, diff --git a/lib/grpc/stub.ex b/lib/grpc/stub.ex index 74f1be0e..a774d2b1 100644 --- a/lib/grpc/stub.ex +++ b/lib/grpc/stub.ex @@ -245,13 +245,9 @@ defmodule GRPC.Stub do opts = if req_stream || response_stream do - opts - |> parse_req_opts() - |> Keyword.put_new(:timeout, :infinity) + parse_req_opts([{:timeout, :infinity} | opts]) else - opts - |> parse_req_opts() - |> Keyword.put_new(:timeout, @default_timeout) + parse_req_opts([{:timeout, @default_timeout} | opts]) end compressor = Keyword.get(opts, :compressor, channel.compressor) @@ -616,7 +612,10 @@ defmodule GRPC.Stub do :return_headers ] defp parse_req_opts(opts) when is_list(opts) do - Enum.map(opts, fn + # Map.new is used so we can keep the last value + # passed for a given key + opts + |> Map.new(fn {:deadline, deadline} -> {:timeout, GRPC.TimeUtils.to_relative(deadline)} @@ -626,10 +625,15 @@ defmodule GRPC.Stub do {key, _} -> raise ArgumentError, "option #{inspect(key)} is not supported" end) + |> Map.to_list() end defp parse_recv_opts(list) when is_list(list) do - Enum.map(list, fn + # Map.new is used so we can keep the last value + # passed for a given key + + list + |> Map.new(fn {:deadline, deadline} -> {:deadline, GRPC.TimeUtils.to_relative(deadline)} @@ -639,5 +643,6 @@ defmodule GRPC.Stub do kv -> kv end) + |> Map.to_list() end end