Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 1 | // Copyright 2015 gRPC authors. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 2 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 6 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 8 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 14 | |
| 15 | syntax = "proto3"; |
| 16 | |
Eric Anderson | 8d3ae46 | 2016-02-03 10:07:44 -0800 | [diff] [blame] | 17 | option java_multiple_files = true; |
| 18 | option java_package = "io.grpc.examples.routeguide"; |
| 19 | option java_outer_classname = "RouteGuideProto"; |
Jorge Canizales | e3534c3 | 2015-06-02 02:02:28 -0700 | [diff] [blame] | 20 | option objc_class_prefix = "RTG"; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 21 | |
yang-g | 9a72021 | 2015-08-31 13:14:13 -0700 | [diff] [blame] | 22 | package routeguide; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 23 | |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 24 | // Interface exported by the server. |
| 25 | service RouteGuide { |
| 26 | // A simple RPC. |
| 27 | // |
| 28 | // Obtains the feature at a given position. |
Daniel Wang | b224d6a | 2015-02-25 16:03:09 -0800 | [diff] [blame] | 29 | // |
| 30 | // A feature with an empty name is returned if there's no feature at the given |
| 31 | // position. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 32 | rpc GetFeature(Point) returns (Feature) {} |
| 33 | |
| 34 | // A server-to-client streaming RPC. |
| 35 | // |
| 36 | // Obtains the Features available within the given Rectangle. Results are |
| 37 | // streamed rather than returned at once (e.g. in a response message with a |
| 38 | // repeated field), as the rectangle may cover a large area and contain a |
| 39 | // huge number of features. |
| 40 | rpc ListFeatures(Rectangle) returns (stream Feature) {} |
| 41 | |
| 42 | // A client-to-server streaming RPC. |
| 43 | // |
| 44 | // Accepts a stream of Points on a route being traversed, returning a |
| 45 | // RouteSummary when traversal is completed. |
| 46 | rpc RecordRoute(stream Point) returns (RouteSummary) {} |
| 47 | |
| 48 | // A Bidirectional streaming RPC. |
| 49 | // |
| 50 | // Accepts a stream of RouteNotes sent while a route is being traversed, |
| 51 | // while receiving other RouteNotes (e.g. from other users). |
| 52 | rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} |
| 53 | } |
| 54 | |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 55 | // Points are represented as latitude-longitude pairs in the E7 representation |
| 56 | // (degrees multiplied by 10**7 and rounded to the nearest integer). |
| 57 | // Latitudes should be in the range +/- 90 degrees and longitude should be in |
| 58 | // the range +/- 180 degrees (inclusive). |
| 59 | message Point { |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 60 | int32 latitude = 1; |
| 61 | int32 longitude = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | // A latitude-longitude rectangle, represented as two diagonally opposite |
| 65 | // points "lo" and "hi". |
| 66 | message Rectangle { |
| 67 | // One corner of the rectangle. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 68 | Point lo = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 69 | |
| 70 | // The other corner of the rectangle. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 71 | Point hi = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | // A feature names something at a given point. |
| 75 | // |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 76 | // If a feature could not be named, the name is empty. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 77 | message Feature { |
| 78 | // The name of the feature. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 79 | string name = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 80 | |
| 81 | // The point where the feature is detected. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 82 | Point location = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | // A RouteNote is a message sent while at a given point. |
| 86 | message RouteNote { |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 87 | // The location from which the message is sent. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 88 | Point location = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 89 | |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 90 | // The message to be sent. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 91 | string message = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 94 | // A RouteSummary is received in response to a RecordRoute rpc. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 95 | // |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 96 | // It contains the number of individual points received, the number of |
| 97 | // detected features, and the total distance covered as the cumulative sum of |
| 98 | // the distance between each point. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 99 | message RouteSummary { |
| 100 | // The number of points received. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 101 | int32 point_count = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 102 | |
| 103 | // The number of known features passed while traversing the route. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 104 | int32 feature_count = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 105 | |
| 106 | // The distance covered in metres. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 107 | int32 distance = 3; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 108 | |
| 109 | // The duration of the traversal in seconds. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 110 | int32 elapsed_time = 4; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 111 | } |