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