Eric Anderson | 04c97a1 | 2016-02-03 14:38:39 -0800 | [diff] [blame] | 1 | // Copyright 2015-2016, Google Inc. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 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 | |
| 30 | syntax = "proto3"; |
| 31 | |
Eric Anderson | 8d3ae46 | 2016-02-03 10:07:44 -0800 | [diff] [blame] | 32 | option java_multiple_files = true; |
| 33 | option java_package = "io.grpc.examples.routeguide"; |
| 34 | option java_outer_classname = "RouteGuideProto"; |
Jorge Canizales | e3534c3 | 2015-06-02 02:02:28 -0700 | [diff] [blame] | 35 | option objc_class_prefix = "RTG"; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 36 | |
yang-g | 9a72021 | 2015-08-31 13:14:13 -0700 | [diff] [blame] | 37 | package routeguide; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 38 | |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 39 | // Interface exported by the server. |
| 40 | service RouteGuide { |
| 41 | // A simple RPC. |
| 42 | // |
| 43 | // Obtains the feature at a given position. |
Daniel Wang | b224d6a | 2015-02-25 16:03:09 -0800 | [diff] [blame] | 44 | // |
| 45 | // A feature with an empty name is returned if there's no feature at the given |
| 46 | // position. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 47 | rpc GetFeature(Point) returns (Feature) {} |
| 48 | |
| 49 | // A server-to-client streaming RPC. |
| 50 | // |
| 51 | // Obtains the Features available within the given Rectangle. Results are |
| 52 | // streamed rather than returned at once (e.g. in a response message with a |
| 53 | // repeated field), as the rectangle may cover a large area and contain a |
| 54 | // huge number of features. |
| 55 | rpc ListFeatures(Rectangle) returns (stream Feature) {} |
| 56 | |
| 57 | // A client-to-server streaming RPC. |
| 58 | // |
| 59 | // Accepts a stream of Points on a route being traversed, returning a |
| 60 | // RouteSummary when traversal is completed. |
| 61 | rpc RecordRoute(stream Point) returns (RouteSummary) {} |
| 62 | |
| 63 | // A Bidirectional streaming RPC. |
| 64 | // |
| 65 | // Accepts a stream of RouteNotes sent while a route is being traversed, |
| 66 | // while receiving other RouteNotes (e.g. from other users). |
| 67 | rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} |
| 68 | } |
| 69 | |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 70 | // Points are represented as latitude-longitude pairs in the E7 representation |
| 71 | // (degrees multiplied by 10**7 and rounded to the nearest integer). |
| 72 | // Latitudes should be in the range +/- 90 degrees and longitude should be in |
| 73 | // the range +/- 180 degrees (inclusive). |
| 74 | message Point { |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 75 | int32 latitude = 1; |
| 76 | int32 longitude = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | // A latitude-longitude rectangle, represented as two diagonally opposite |
| 80 | // points "lo" and "hi". |
| 81 | message Rectangle { |
| 82 | // One corner of the rectangle. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 83 | Point lo = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 84 | |
| 85 | // The other corner of the rectangle. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 86 | Point hi = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | // A feature names something at a given point. |
| 90 | // |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 91 | // If a feature could not be named, the name is empty. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 92 | message Feature { |
| 93 | // The name of the feature. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 94 | string name = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 95 | |
| 96 | // The point where the feature is detected. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 97 | Point location = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | // A RouteNote is a message sent while at a given point. |
| 101 | message RouteNote { |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 102 | // The location from which the message is sent. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 103 | Point location = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 104 | |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 105 | // The message to be sent. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 106 | string message = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 107 | } |
| 108 | |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 109 | // A RouteSummary is received in response to a RecordRoute rpc. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 110 | // |
Tim Emiola | 9ab2c8b | 2015-02-18 08:08:15 -0800 | [diff] [blame] | 111 | // It contains the number of individual points received, the number of |
| 112 | // detected features, and the total distance covered as the cumulative sum of |
| 113 | // the distance between each point. |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 114 | message RouteSummary { |
| 115 | // The number of points received. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 116 | int32 point_count = 1; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 117 | |
| 118 | // The number of known features passed while traversing the route. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 119 | int32 feature_count = 2; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 120 | |
| 121 | // The distance covered in metres. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 122 | int32 distance = 3; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 123 | |
| 124 | // The duration of the traversal in seconds. |
Tim Emiola | c1ee382 | 2015-02-18 14:15:05 -0800 | [diff] [blame] | 125 | int32 elapsed_time = 4; |
Tim Emiola | 23307f2 | 2015-02-18 04:12:18 -0800 | [diff] [blame] | 126 | } |