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