echo.proto 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright 2019 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. syntax = "proto3";
  15. package grpc.gateway.testing;
  16. message Empty {}
  17. message EchoRequest {
  18. string message = 1;
  19. }
  20. message EchoResponse {
  21. string message = 1;
  22. int32 message_count = 2;
  23. }
  24. // Request type for server side streaming echo.
  25. message ServerStreamingEchoRequest {
  26. // Message string for server streaming request.
  27. string message = 1;
  28. // The total number of messages to be generated before the server
  29. // closes the stream; default is 10.
  30. int32 message_count = 2;
  31. // The interval (ms) between two server messages. The server implementation
  32. // may enforce some minimum interval (e.g. 100ms) to avoid message overflow.
  33. int32 message_interval = 3;
  34. }
  35. // Response type for server streaming response.
  36. message ServerStreamingEchoResponse {
  37. // Response message.
  38. string message = 1;
  39. }
  40. // Request type for client side streaming echo.
  41. message ClientStreamingEchoRequest {
  42. // A special value "" indicates that there's no further messages.
  43. string message = 1;
  44. }
  45. // Response type for client side streaming echo.
  46. message ClientStreamingEchoResponse {
  47. // Total number of client messages that have been received.
  48. int32 message_count = 1;
  49. }
  50. // A simple echo service.
  51. service EchoService {
  52. // One request followed by one response
  53. // The server returns the client message as-is.
  54. rpc Echo(EchoRequest) returns (EchoResponse);
  55. // Sends back abort status.
  56. rpc EchoAbort(EchoRequest) returns (EchoResponse) {}
  57. // One empty request, ZERO processing, followed by one empty response
  58. // (minimum effort to do message serialization).
  59. rpc NoOp(Empty) returns (Empty);
  60. // One request followed by a sequence of responses (streamed download).
  61. // The server will return the same client message repeatedly.
  62. rpc ServerStreamingEcho(ServerStreamingEchoRequest)
  63. returns (stream ServerStreamingEchoResponse);
  64. // One request followed by a sequence of responses (streamed download).
  65. // The server abort directly.
  66. rpc ServerStreamingEchoAbort(ServerStreamingEchoRequest)
  67. returns (stream ServerStreamingEchoResponse) {}
  68. // A sequence of requests followed by one response (streamed upload).
  69. // The server returns the total number of messages as the result.
  70. rpc ClientStreamingEcho(stream ClientStreamingEchoRequest)
  71. returns (ClientStreamingEchoResponse);
  72. // A sequence of requests with each message echoed by the server immediately.
  73. // The server returns the same client messages in order.
  74. // E.g. this is how the speech API works.
  75. rpc FullDuplexEcho(stream EchoRequest) returns (stream EchoResponse);
  76. // A sequence of requests followed by a sequence of responses.
  77. // The server buffers all the client messages and then returns the same
  78. // client messages one by one after the client half-closes the stream.
  79. // This is how an image recognition API may work.
  80. rpc HalfDuplexEcho(stream EchoRequest) returns (stream EchoResponse);
  81. }