diff --git a/mix.exs b/mix.exs index 4940ff73..73c14657 100644 --- a/mix.exs +++ b/mix.exs @@ -36,8 +36,7 @@ defmodule GRPC.Mixfile do defp deps do [ - # TO-DO: update protobuf to 0.10 (has breaking changes) - {:protobuf, "~> 0.9.0"}, + {:protobuf, "~> 0.10"}, {:cowboy, "~> 2.9"}, {:gun, "~> 2.0.0-rc.2"}, {:cowlib, "~> 2.11"}, diff --git a/mix.lock b/mix.lock index 7e94566a..4feda205 100644 --- a/mix.lock +++ b/mix.lock @@ -13,6 +13,6 @@ "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, - "protobuf": {:hex, :protobuf, "0.9.0", "9c1633ecc098f3d7ec0a00503e070541b0e1868114fff41523934888442319e7", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "15fb7cddc5f85b8055fedaf81a9093020e4cd283647a21deb8f7de8d243abb9d"}, + "protobuf": {:hex, :protobuf, "0.10.0", "4e8e3cf64c5be203b329f88bb8b916cb8d00fb3a12b2ac1f545463ae963c869f", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "4ae21a386142357aa3d31ccf5f7d290f03f3fa6f209755f6e87fc2c58c147893"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, } diff --git a/test/grpc/integration/service_test.exs b/test/grpc/integration/service_test.exs index 2ac79556..497bf1cd 100644 --- a/test/grpc/integration/service_test.exs +++ b/test/grpc/integration/service_test.exs @@ -132,7 +132,7 @@ defmodule GRPC.Integration.ServiceTest do FeatureServer, fn port -> {:ok, channel} = GRPC.Stub.connect("localhost:#{port}") - stream = channel |> Routeguide.RouteGuide.Stub.async_route_chat() + stream = channel |> Routeguide.RouteGuide.Stub.route_chat() task = Task.async(fn -> diff --git a/test/grpc/message/protobuf_test.exs b/test/grpc/message/protobuf_test.exs index 3e1b8dae..243a5b2d 100644 --- a/test/grpc/message/protobuf_test.exs +++ b/test/grpc/message/protobuf_test.exs @@ -2,16 +2,14 @@ defmodule GRPC.Message.ProtobufTest do use ExUnit.Case, async: true defmodule Helloworld.HelloRequest do - use Protobuf + use Protobuf, syntax: :proto3 - defstruct [:name] field(:name, 1, optional: true, type: :string) end defmodule Helloworld.HelloReply do - use Protobuf + use Protobuf, syntax: :proto3 - defstruct [:message] field(:message, 1, optional: true, type: :string) end diff --git a/test/support/helloworld.pb.ex b/test/support/helloworld.pb.ex index f8758c31..1da2351c 100644 --- a/test/support/helloworld.pb.ex +++ b/test/support/helloworld.pb.ex @@ -1,52 +1,35 @@ defmodule Helloworld.HelloRequest do @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - name: String.t() - } - defstruct [:name] + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 field :name, 1, type: :string end defmodule Helloworld.HelloReply do @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - message: String.t() - } - defstruct [:message] + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 field :message, 1, type: :string end defmodule Helloworld.HeaderRequest do @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{} - defstruct [] + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 end defmodule Helloworld.HeaderReply do @moduledoc false - use Protobuf, syntax: :proto3 - - @type t :: %__MODULE__{ - authorization: String.t() - } - defstruct [:authorization] + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 field :authorization, 1, type: :string end defmodule Helloworld.Greeter.Service do @moduledoc false - use GRPC.Service, name: "helloworld.Greeter" + use GRPC.Service, name: "helloworld.Greeter", protoc_gen_elixir_version: "0.10.0" rpc :SayHello, Helloworld.HelloRequest, Helloworld.HelloReply + rpc :CheckHeaders, Helloworld.HeaderRequest, Helloworld.HeaderReply end diff --git a/test/support/route_guide.pb.ex b/test/support/route_guide.pb.ex index 6ad6f559..66a64c91 100644 --- a/test/support/route_guide.pb.ex +++ b/test/support/route_guide.pb.ex @@ -1,82 +1,59 @@ defmodule Routeguide.Point do - use Protobuf + @moduledoc false + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 - @type t :: %__MODULE__{ - latitude: integer, - longitude: integer - } - defstruct [:latitude, :longitude] - - field :latitude, 1, optional: true, type: :int32 - field :longitude, 2, optional: true, type: :int32 + field :latitude, 1, type: :int32 + field :longitude, 2, type: :int32 end defmodule Routeguide.Rectangle do - use Protobuf - - @type t :: %__MODULE__{ - lo: Routeguide.Point.t(), - hi: Routeguide.Point.t() - } - defstruct [:lo, :hi] + @moduledoc false + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 - field :lo, 1, optional: true, type: Routeguide.Point - field :hi, 2, optional: true, type: Routeguide.Point + field :lo, 1, type: Routeguide.Point + field :hi, 2, type: Routeguide.Point end defmodule Routeguide.Feature do - use Protobuf + @moduledoc false + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 - @type t :: %__MODULE__{ - name: String.t(), - location: Routeguide.Point.t() - } - defstruct [:name, :location] - - field :name, 1, optional: true, type: :string - field :location, 2, optional: true, type: Routeguide.Point + field :name, 1, type: :string + field :location, 2, type: Routeguide.Point end defmodule Routeguide.RouteNote do - use Protobuf - - @type t :: %__MODULE__{ - location: Routeguide.Point.t(), - message: String.t() - } - defstruct [:location, :message] + @moduledoc false + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 - field :location, 1, optional: true, type: Routeguide.Point - field :message, 2, optional: true, type: :string + field :location, 1, type: Routeguide.Point + field :message, 2, type: :string end defmodule Routeguide.RouteSummary do - use Protobuf + @moduledoc false + use Protobuf, protoc_gen_elixir_version: "0.10.0", syntax: :proto3 - @type t :: %__MODULE__{ - point_count: integer, - feature_count: integer, - distance: integer, - elapsed_time: integer - } - defstruct [:point_count, :feature_count, :distance, :elapsed_time] - - field :point_count, 1, optional: true, type: :int32 - field :feature_count, 2, optional: true, type: :int32 - field :distance, 3, optional: true, type: :int32 - field :elapsed_time, 4, optional: true, type: :int32 + field :point_count, 1, type: :int32, json_name: "pointCount" + field :feature_count, 2, type: :int32, json_name: "featureCount" + field :distance, 3, type: :int32 + field :elapsed_time, 4, type: :int32, json_name: "elapsedTime" end defmodule Routeguide.RouteGuide.Service do - use GRPC.Service, name: "routeguide.RouteGuide" + @moduledoc false + use GRPC.Service, name: "routeguide.RouteGuide", protoc_gen_elixir_version: "0.10.0" rpc :GetFeature, Routeguide.Point, Routeguide.Feature + rpc :ListFeatures, Routeguide.Rectangle, stream(Routeguide.Feature) + rpc :RecordRoute, stream(Routeguide.Point), Routeguide.RouteSummary + rpc :RouteChat, stream(Routeguide.RouteNote), stream(Routeguide.RouteNote) - rpc :AsyncRouteChat, stream(Routeguide.RouteNote), stream(Routeguide.RouteNote) end defmodule Routeguide.RouteGuide.Stub do + @moduledoc false use GRPC.Stub, service: Routeguide.RouteGuide.Service end