Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 1 | // Copyright 2016, 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 | |
| 30 | // Service exported by server reflection |
| 31 | |
| 32 | syntax = "proto3"; |
| 33 | |
| 34 | package grpc.reflection.v1alpha; |
| 35 | |
| 36 | service ServerReflection { |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 37 | // The reflection service is structured as a bidirectional stream, ensuring |
| 38 | // all related requests go to a single server. |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 39 | rpc ServerReflectionInfo(stream ServerReflectionRequest) |
| 40 | returns (stream ServerReflectionResponse); |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 41 | } |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 42 | |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 43 | // The message sent by the client when calling ServerReflectionInfo method. |
| 44 | message ServerReflectionRequest { |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 45 | string host = 1; |
| 46 | // To use reflection service, the client should set one of the following |
| 47 | // fields in message_request. The server distinguishes requests by their |
| 48 | // defined field and then handles them using corresponding methods. |
| 49 | oneof message_request { |
| 50 | // Find a proto file by the file name. |
| 51 | string file_by_filename = 3; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 52 | |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 53 | // Find the proto file that declares the given fully-qualified symbol name. |
| 54 | // This field should be a fully-qualified symbol name |
| 55 | // (e.g. <package>.<service>[.<method>] or <package>.<type>). |
| 56 | string file_containing_symbol = 4; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 57 | |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 58 | // Find the proto file which defines an extension extending the given |
| 59 | // message type with the given field number. |
| 60 | ExtensionRequest file_containing_extension = 5; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 61 | |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 62 | // Finds the tag numbers used by all known extensions of extendee_type, and |
| 63 | // appends them to ExtensionNumberResponse in an undefined order. |
| 64 | // Its corresponding method is best-effort: it's not guaranteed that the |
| 65 | // reflection service will implement this method, and it's not guaranteed |
| 66 | // that this method will provide all extensions. Returns |
| 67 | // StatusCode::UNIMPLEMENTED if it's not implemented. |
| 68 | // This field should be a fully-qualified type name. The format is |
| 69 | // <package>.<type> |
| 70 | string all_extension_numbers_of_type = 6; |
| 71 | |
| 72 | // List the full names of registered services. The content will not be |
| 73 | // checked. |
| 74 | string list_services = 7; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 78 | // The type name and extension number sent by the client when requesting |
| 79 | // file_containing_extension. |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 80 | message ExtensionRequest { |
Yuchen Zeng | d50b58c | 2016-05-03 18:38:29 -0700 | [diff] [blame] | 81 | // Fully-qualified type name. The format should be <package>.<type> |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 82 | string containing_type = 1; |
| 83 | int32 extension_number = 2; |
| 84 | } |
| 85 | |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 86 | // The message sent by the server to answer ServerReflectionInfo method. |
| 87 | message ServerReflectionResponse { |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 88 | string valid_host = 1; |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 89 | ServerReflectionRequest original_request = 2; |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 90 | // The server set one of the following fields accroding to the message_request |
| 91 | // in the request. |
| 92 | oneof message_response { |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 93 | // This message is used to answer file_by_filename, file_containing_symbol, |
| 94 | // file_containing_extension requests with transitive dependencies. As |
| 95 | // the repeated label is not allowed in oneof fields, we use a |
| 96 | // FileDescriptorResponse message to encapsulate the repeated fields. |
Yuchen Zeng | 2ea66c3 | 2016-05-12 16:26:48 -0700 | [diff] [blame] | 97 | // The reflection service is allowed to avoid sending FileDescriptorProtos |
| 98 | // that were previously sent in response to earlier requests in the stream. |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 99 | FileDescriptorResponse file_descriptor_response = 4; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 100 | |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 101 | // This message is used to answer all_extension_numbers_of_type requst. |
| 102 | ExtensionNumberResponse all_extension_numbers_response = 5; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 103 | |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 104 | // This message is used to answer list_services request. |
| 105 | ListServiceResponse list_services_response = 6; |
| 106 | |
| 107 | // This message is used when an error occurs. |
| 108 | ErrorResponse error_response = 7; |
| 109 | } |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 112 | // Serialized FileDescriptorProto messages sent by the server answering |
| 113 | // a file_by_filename, file_containing_symbol, or file_containing_extension |
| 114 | // request. |
| 115 | message FileDescriptorResponse { |
| 116 | // Serialized FileDescriptorProto messages. We avoid taking a dependency on |
| 117 | // descriptor.proto, which uses proto2 only features, by making them opaque |
| 118 | // bytes instead. |
| 119 | repeated bytes file_descriptor_proto = 1; |
| 120 | } |
| 121 | |
Yuchen Zeng | d50b58c | 2016-05-03 18:38:29 -0700 | [diff] [blame] | 122 | // A list of extension numbers sent by the server answering |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 123 | // all_extension_numbers_of_type request. |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 124 | message ExtensionNumberResponse { |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 125 | // Full name of the base type, including the package name. The format |
| 126 | // is <package>.<type> |
| 127 | string base_type_name = 1; |
| 128 | repeated int32 extension_number = 2; |
| 129 | } |
| 130 | |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 131 | // A list of ServiceResponse sent by the server answering list_services request. |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 132 | message ListServiceResponse { |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 133 | // The information of each service may be expanded in the future, so we use |
| 134 | // ServiceResponse message to encapsulate it. |
| 135 | repeated ServiceResponse service = 1; |
| 136 | } |
| 137 | |
| 138 | // The information of a single service used by ListServiceResponse to answer |
| 139 | // list_services request. |
| 140 | message ServiceResponse { |
| 141 | // Full name of a registered service, including its package name. The format |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 142 | // is <package>.<service> |
Yuchen Zeng | a782375 | 2016-05-11 17:23:14 -0700 | [diff] [blame] | 143 | string name = 1; |
Yuchen Zeng | 175dbbc | 2016-05-05 11:29:07 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | // The error code and error message sent by the server when an error occurs. |
| 147 | message ErrorResponse { |
| 148 | // This field uses the error codes defined in grpc::StatusCode. |
| 149 | int32 error_code = 1; |
| 150 | string error_message = 2; |
Yuchen Zeng | c553034 | 2016-05-03 15:42:45 -0700 | [diff] [blame] | 151 | } |