Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

175 řádky
5.6 KiB

  1. // Copyright 2017 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. // An integration test service that covers all the method signature permutations
  15. // of unary/streaming requests/responses.
  16. syntax = "proto3";
  17. package grpc.testing;
  18. message Empty {}
  19. // The type of payload that should be returned.
  20. enum PayloadType {
  21. // Compressable text format.
  22. COMPRESSABLE = 0;
  23. // Uncompressable binary format.
  24. UNCOMPRESSABLE = 1;
  25. // Randomly chosen from all other formats defined in this enum.
  26. RANDOM = 2;
  27. }
  28. // A block of data, to simply increase gRPC message size.
  29. message Payload {
  30. // The type of data in body.
  31. PayloadType type = 1;
  32. // Primary contents of payload.
  33. bytes body = 2;
  34. }
  35. // A protobuf representation for grpc status. This is used by test
  36. // clients to specify a status that the server should attempt to return.
  37. message EchoStatus {
  38. int32 code = 1;
  39. string message = 2;
  40. }
  41. // Unary request.
  42. message SimpleRequest {
  43. // Desired payload type in the response from the server.
  44. // If response_type is RANDOM, server randomly chooses one from other formats.
  45. PayloadType response_type = 1;
  46. // Desired payload size in the response from the server.
  47. // If response_type is COMPRESSABLE, this denotes the size before compression.
  48. int32 response_size = 2;
  49. // Optional input payload sent along with the request.
  50. Payload payload = 3;
  51. // Whether SimpleResponse should include username.
  52. bool fill_username = 4;
  53. // Whether SimpleResponse should include OAuth scope.
  54. bool fill_oauth_scope = 5;
  55. // Whether server should return a given status
  56. EchoStatus response_status = 7;
  57. }
  58. // Unary response, as configured by the request.
  59. message SimpleResponse {
  60. // Payload to increase message size.
  61. Payload payload = 1;
  62. // The user the request came from, for verifying authentication was
  63. // successful when the client expected it.
  64. string username = 2;
  65. // OAuth scope.
  66. string oauth_scope = 3;
  67. }
  68. // Client-streaming request.
  69. message StreamingInputCallRequest {
  70. // Optional input payload sent along with the request.
  71. Payload payload = 1;
  72. // Not expecting any payload from the response.
  73. }
  74. // Client-streaming response.
  75. message StreamingInputCallResponse {
  76. // Aggregated size of payloads received from the client.
  77. int32 aggregated_payload_size = 1;
  78. }
  79. // Configuration for a particular response.
  80. message ResponseParameters {
  81. // Desired payload sizes in responses from the server.
  82. // If response_type is COMPRESSABLE, this denotes the size before compression.
  83. int32 size = 1;
  84. // Desired interval between consecutive responses in the response stream in
  85. // microseconds.
  86. int32 interval_us = 2;
  87. }
  88. // Server-streaming request.
  89. message StreamingOutputCallRequest {
  90. // Desired payload type in the response from the server.
  91. // If response_type is RANDOM, the payload from each response in the stream
  92. // might be of different types. This is to simulate a mixed type of payload
  93. // stream.
  94. PayloadType response_type = 1;
  95. // Configuration for each expected response message.
  96. repeated ResponseParameters response_parameters = 2;
  97. // Optional input payload sent along with the request.
  98. Payload payload = 3;
  99. // Whether server should return a given status
  100. EchoStatus response_status = 7;
  101. }
  102. // Server-streaming response, as configured by the request and parameters.
  103. message StreamingOutputCallResponse {
  104. // Payload to increase response size.
  105. Payload payload = 1;
  106. }
  107. // A simple service to test the various types of RPCs and experiment with
  108. // performance with various types of payload.
  109. service TestService {
  110. // One empty request followed by one empty response.
  111. rpc EmptyCall(Empty) returns (Empty);
  112. // One request followed by one response.
  113. // The server returns the client payload as-is.
  114. rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
  115. // One request followed by a sequence of responses (streamed download).
  116. // The server returns the payload with client desired type and sizes.
  117. rpc StreamingOutputCall(StreamingOutputCallRequest)
  118. returns (stream StreamingOutputCallResponse);
  119. // A sequence of requests followed by one response (streamed upload).
  120. // The server returns the aggregated size of client payload as the result.
  121. rpc StreamingInputCall(stream StreamingInputCallRequest)
  122. returns (StreamingInputCallResponse);
  123. // A sequence of requests with each request served by the server immediately.
  124. // As one request could lead to multiple responses, this interface
  125. // demonstrates the idea of full duplexing.
  126. rpc FullDuplexCall(stream StreamingOutputCallRequest)
  127. returns (stream StreamingOutputCallResponse);
  128. // A sequence of requests followed by a sequence of responses.
  129. // The server buffers all the client requests and then serves them in order. A
  130. // stream of responses are returned to the client when the server starts with
  131. // first request.
  132. rpc HalfDuplexCall(stream StreamingOutputCallRequest)
  133. returns (stream StreamingOutputCallResponse);
  134. }
  135. // A simple service NOT implemented at servers so clients can test for
  136. // that case.
  137. service UnimplementedService {
  138. // A call that no server should implement
  139. rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty);
  140. }