-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: revise route_guide example (#245)
* Change supervisor declaration in tree. * Cleanup dependencies. * Use jason instead of poison. * Auto start server. * Move route_guide.proto to priv/protos.
- Loading branch information
Showing
8 changed files
with
47 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import Config | ||
|
||
# config :grpc, start_server: true | ||
config :grpc, start_server: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +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) | ||
end | ||
|
||
defmodule Routeguide.RouteGuide.Stub do | ||
@moduledoc false | ||
use GRPC.Stub, service: Routeguide.RouteGuide.Service | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
%{ | ||
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"}, | ||
"cowlib": {:hex, :grpc_cowlib, "2.8.1", "ddaf77f3b89bd8e6c76df67b28a4b069688eef91c0c497a246cf9bfcdf87f7d3", [:rebar3], [], "hexpm", "0366f82719d24af4ce45a6591f52a7fc859785823fde4cd84e0dc45119b5ed89"}, | ||
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm", "6c32a70ed5d452c6650916555b1f96c79af5fc4bf286997f8b15f213de786f73"}, | ||
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"}, | ||
"dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"}, | ||
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, | ||
"gun": {:hex, :gun, "2.0.0-rc.2", "7c489a32dedccb77b6e82d1f3c5a7dadfbfa004ec14e322cdb5e579c438632d2", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "6b9d1eae146410d727140dbf8b404b9631302ecc2066d1d12f22097ad7d254fc"}, | ||
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"}, | ||
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, | ||
"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"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.