2
0

reflection.proto 5.6 KB

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