route_guide.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright 2015, Google Inc.
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. syntax = "proto3";
  30. option java_package = "ex.grpc";
  31. package examples;
  32. // Interface exported by the server.
  33. service RouteGuide {
  34. // A simple RPC.
  35. //
  36. // Obtains the feature at a given position.
  37. //
  38. // A feature with an empty name is returned if there's no feature at the given
  39. // position.
  40. rpc GetFeature(Point) returns (Feature) {}
  41. // A server-to-client streaming RPC.
  42. //
  43. // Obtains the Features available within the given Rectangle. Results are
  44. // streamed rather than returned at once (e.g. in a response message with a
  45. // repeated field), as the rectangle may cover a large area and contain a
  46. // huge number of features.
  47. rpc ListFeatures(Rectangle) returns (stream Feature) {}
  48. // A client-to-server streaming RPC.
  49. //
  50. // Accepts a stream of Points on a route being traversed, returning a
  51. // RouteSummary when traversal is completed.
  52. rpc RecordRoute(stream Point) returns (RouteSummary) {}
  53. // A Bidirectional streaming RPC.
  54. //
  55. // Accepts a stream of RouteNotes sent while a route is being traversed,
  56. // while receiving other RouteNotes (e.g. from other users).
  57. rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
  58. }
  59. // Points are represented as latitude-longitude pairs in the E7 representation
  60. // (degrees multiplied by 10**7 and rounded to the nearest integer).
  61. // Latitudes should be in the range +/- 90 degrees and longitude should be in
  62. // the range +/- 180 degrees (inclusive).
  63. message Point {
  64. int32 latitude = 1;
  65. int32 longitude = 2;
  66. }
  67. // A latitude-longitude rectangle, represented as two diagonally opposite
  68. // points "lo" and "hi".
  69. message Rectangle {
  70. // One corner of the rectangle.
  71. Point lo = 1;
  72. // The other corner of the rectangle.
  73. Point hi = 2;
  74. }
  75. // A feature names something at a given point.
  76. //
  77. // If a feature could not be named, the name is empty.
  78. message Feature {
  79. // The name of the feature.
  80. string name = 1;
  81. // The point where the feature is detected.
  82. Point location = 2;
  83. }
  84. // A RouteNote is a message sent while at a given point.
  85. message RouteNote {
  86. // The location from which the message is sent.
  87. Point location = 1;
  88. // The message to be sent.
  89. string message = 2;
  90. }
  91. // A RouteSummary is received in response to a RecordRoute rpc.
  92. //
  93. // It contains the number of individual points received, the number of
  94. // detected features, and the total distance covered as the cumulative sum of
  95. // the distance between each point.
  96. message RouteSummary {
  97. // The number of points received.
  98. int32 point_count = 1;
  99. // The number of known features passed while traversing the route.
  100. int32 feature_count = 2;
  101. // The distance covered in metres.
  102. int32 distance = 3;
  103. // The duration of the traversal in seconds.
  104. int32 elapsed_time = 4;
  105. }