You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

155 lines
5.0 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. // Unary request.
  36. message SimpleRequest {
  37. // Desired payload type in the response from the server.
  38. // If response_type is RANDOM, server randomly chooses one from other formats.
  39. PayloadType response_type = 1;
  40. // Desired payload size in the response from the server.
  41. // If response_type is COMPRESSABLE, this denotes the size before compression.
  42. int32 response_size = 2;
  43. // Optional input payload sent along with the request.
  44. Payload payload = 3;
  45. // Whether SimpleResponse should include username.
  46. bool fill_username = 4;
  47. // Whether SimpleResponse should include OAuth scope.
  48. bool fill_oauth_scope = 5;
  49. }
  50. // Unary response, as configured by the request.
  51. message SimpleResponse {
  52. // Payload to increase message size.
  53. Payload payload = 1;
  54. // The user the request came from, for verifying authentication was
  55. // successful when the client expected it.
  56. string username = 2;
  57. // OAuth scope.
  58. string oauth_scope = 3;
  59. }
  60. // Client-streaming request.
  61. message StreamingInputCallRequest {
  62. // Optional input payload sent along with the request.
  63. Payload payload = 1;
  64. // Not expecting any payload from the response.
  65. }
  66. // Client-streaming response.
  67. message StreamingInputCallResponse {
  68. // Aggregated size of payloads received from the client.
  69. int32 aggregated_payload_size = 1;
  70. }
  71. // Configuration for a particular response.
  72. message ResponseParameters {
  73. // Desired payload sizes in responses from the server.
  74. // If response_type is COMPRESSABLE, this denotes the size before compression.
  75. int32 size = 1;
  76. // Desired interval between consecutive responses in the response stream in
  77. // microseconds.
  78. int32 interval_us = 2;
  79. }
  80. // Server-streaming request.
  81. message StreamingOutputCallRequest {
  82. // Desired payload type in the response from the server.
  83. // If response_type is RANDOM, the payload from each response in the stream
  84. // might be of different types. This is to simulate a mixed type of payload
  85. // stream.
  86. PayloadType response_type = 1;
  87. // Configuration for each expected response message.
  88. repeated ResponseParameters response_parameters = 2;
  89. // Optional input payload sent along with the request.
  90. Payload payload = 3;
  91. }
  92. // Server-streaming response, as configured by the request and parameters.
  93. message StreamingOutputCallResponse {
  94. // Payload to increase response size.
  95. Payload payload = 1;
  96. }
  97. // A simple service to test the various types of RPCs and experiment with
  98. // performance with various types of payload.
  99. service TestService {
  100. // One empty request followed by one empty response.
  101. rpc EmptyCall(Empty) returns (Empty);
  102. // One request followed by one response.
  103. // The server returns the client payload as-is.
  104. rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
  105. // One request followed by a sequence of responses (streamed download).
  106. // The server returns the payload with client desired type and sizes.
  107. rpc StreamingOutputCall(StreamingOutputCallRequest)
  108. returns (stream StreamingOutputCallResponse);
  109. // A sequence of requests followed by one response (streamed upload).
  110. // The server returns the aggregated size of client payload as the result.
  111. rpc StreamingInputCall(stream StreamingInputCallRequest)
  112. returns (StreamingInputCallResponse);
  113. // A sequence of requests with each request served by the server immediately.
  114. // As one request could lead to multiple responses, this interface
  115. // demonstrates the idea of full duplexing.
  116. rpc FullDuplexCall(stream StreamingOutputCallRequest)
  117. returns (stream StreamingOutputCallResponse);
  118. // A sequence of requests followed by a sequence of responses.
  119. // The server buffers all the client requests and then serves them in order. A
  120. // stream of responses are returned to the client when the server starts with
  121. // first request.
  122. rpc HalfDuplexCall(stream StreamingOutputCallRequest)
  123. returns (stream StreamingOutputCallResponse);
  124. }