blob: 276ff0e255d9647e6d053d1db0f8b46ea73e7c03 [file] [log] [blame]
Yuchen Zengc5530342016-05-03 15:42:45 -07001// 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
32syntax = "proto3";
33
34package grpc.reflection.v1alpha;
35
36service ServerReflection {
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070037 // The reflection service is structured as a bidirectional stream, ensuring
38 // all related requests go to a single server.
Yuchen Zenga7823752016-05-11 17:23:14 -070039 rpc ServerReflectionInfo(stream ServerReflectionRequest)
40 returns (stream ServerReflectionResponse);
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070041}
Yuchen Zengc5530342016-05-03 15:42:45 -070042
Yuchen Zenga7823752016-05-11 17:23:14 -070043// The message sent by the client when calling ServerReflectionInfo method.
44message ServerReflectionRequest {
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070045 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 Zengc5530342016-05-03 15:42:45 -070052
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070053 // 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 Zengc5530342016-05-03 15:42:45 -070057
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070058 // 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 Zengc5530342016-05-03 15:42:45 -070061
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070062 // 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 Zengc5530342016-05-03 15:42:45 -070075 }
76}
77
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070078// The type name and extension number sent by the client when requesting
79// file_containing_extension.
Yuchen Zengc5530342016-05-03 15:42:45 -070080message ExtensionRequest {
Yuchen Zengd50b58c2016-05-03 18:38:29 -070081 // Fully-qualified type name. The format should be <package>.<type>
Yuchen Zengc5530342016-05-03 15:42:45 -070082 string containing_type = 1;
83 int32 extension_number = 2;
84}
85
Yuchen Zenga7823752016-05-11 17:23:14 -070086// The message sent by the server to answer ServerReflectionInfo method.
87message ServerReflectionResponse {
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070088 string valid_host = 1;
Yuchen Zenga7823752016-05-11 17:23:14 -070089 ServerReflectionRequest original_request = 2;
Yuchen Zeng175dbbc2016-05-05 11:29:07 -070090 // The server set one of the following fields accroding to the message_request
91 // in the request.
92 oneof message_response {
Yuchen Zenga7823752016-05-11 17:23:14 -070093 // 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 Zeng2ea66c32016-05-12 16:26:48 -070097 // The reflection service is allowed to avoid sending FileDescriptorProtos
98 // that were previously sent in response to earlier requests in the stream.
Yuchen Zenga7823752016-05-11 17:23:14 -070099 FileDescriptorResponse file_descriptor_response = 4;
Yuchen Zengc5530342016-05-03 15:42:45 -0700100
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700101 // This message is used to answer all_extension_numbers_of_type requst.
102 ExtensionNumberResponse all_extension_numbers_response = 5;
Yuchen Zengc5530342016-05-03 15:42:45 -0700103
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700104 // 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 Zengc5530342016-05-03 15:42:45 -0700110}
111
Yuchen Zenga7823752016-05-11 17:23:14 -0700112// Serialized FileDescriptorProto messages sent by the server answering
113// a file_by_filename, file_containing_symbol, or file_containing_extension
114// request.
115message 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 Zengd50b58c2016-05-03 18:38:29 -0700122// A list of extension numbers sent by the server answering
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700123// all_extension_numbers_of_type request.
Yuchen Zengc5530342016-05-03 15:42:45 -0700124message ExtensionNumberResponse {
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700125 // 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 Zenga7823752016-05-11 17:23:14 -0700131// A list of ServiceResponse sent by the server answering list_services request.
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700132message ListServiceResponse {
Yuchen Zenga7823752016-05-11 17:23:14 -0700133 // 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.
140message ServiceResponse {
141 // Full name of a registered service, including its package name. The format
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700142 // is <package>.<service>
Yuchen Zenga7823752016-05-11 17:23:14 -0700143 string name = 1;
Yuchen Zeng175dbbc2016-05-05 11:29:07 -0700144}
145
146// The error code and error message sent by the server when an error occurs.
147message ErrorResponse {
148 // This field uses the error codes defined in grpc::StatusCode.
149 int32 error_code = 1;
150 string error_message = 2;
Yuchen Zengc5530342016-05-03 15:42:45 -0700151}