github.com/jhump/protoreflect@v1.16.0/internal/testprotos/grpc/test.proto (about) 1 // This file was copied from github.com/grpc/grpc-go/interop/grpc_testing. 2 // This fork exists because the original source is unstable and has been 3 // moved/refactored and broken clients. 4 5 // Copyright 2017 gRPC authors. 6 // 7 // Licensed under the Apache License, Version 2.0 (the "License"); 8 // you may not use this file except in compliance with the License. 9 // You may obtain a copy of the License at 10 // 11 // http://www.apache.org/licenses/LICENSE-2.0 12 // 13 // Unless required by applicable law or agreed to in writing, software 14 // distributed under the License is distributed on an "AS IS" BASIS, 15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 // See the License for the specific language governing permissions and 17 // limitations under the License. 18 19 // An integration test service that covers all the method signature permutations 20 // of unary/streaming requests/responses. 21 syntax = "proto3"; 22 23 // NB: we are generating locally into this repo 24 //option go_package = "google.golang.org/grpc/interop/grpc_testing"; 25 option go_package = "github.com/jhump/protoreflect/internal/testprotos/grpc"; 26 27 package grpc.testing; 28 29 import "google/protobuf/empty.proto"; 30 31 // The type of payload that should be returned. 32 enum PayloadType { 33 // Compressable text format. 34 COMPRESSABLE = 0; 35 36 // Uncompressable binary format. 37 UNCOMPRESSABLE = 1; 38 39 // Randomly chosen from all other formats defined in this enum. 40 RANDOM = 2; 41 } 42 43 // A block of data, to simply increase gRPC message size. 44 message Payload { 45 // The type of data in body. 46 PayloadType type = 1; 47 // Primary contents of payload. 48 bytes body = 2; 49 } 50 51 // A protobuf representation for grpc status. This is used by test 52 // clients to specify a status that the server should attempt to return. 53 message EchoStatus { 54 int32 code = 1; 55 string message = 2; 56 } 57 58 // The type of route that a client took to reach a server w.r.t. gRPCLB. 59 // The server must fill in "fallback" if it detects that the RPC reached 60 // the server via the "gRPCLB fallback" path, and "backend" if it detects 61 // that the RPC reached the server via "gRPCLB backend" path (i.e. if it got 62 // the address of this server from the gRPCLB server BalanceLoad RPC). Exactly 63 // how this detection is done is context and server dependant. 64 enum GrpclbRouteType { 65 // Server didn't detect the route that a client took to reach it. 66 GRPCLB_ROUTE_TYPE_UNKNOWN = 0; 67 // Indicates that a client reached a server via gRPCLB fallback. 68 GRPCLB_ROUTE_TYPE_FALLBACK = 1; 69 // Indicates that a client reached a server as a gRPCLB-given backend. 70 GRPCLB_ROUTE_TYPE_BACKEND = 2; 71 } 72 73 // Unary request. 74 message SimpleRequest { 75 // Desired payload type in the response from the server. 76 // If response_type is RANDOM, server randomly chooses one from other formats. 77 PayloadType response_type = 1; 78 79 // Desired payload size in the response from the server. 80 // If response_type is COMPRESSABLE, this denotes the size before compression. 81 int32 response_size = 2; 82 83 // Optional input payload sent along with the request. 84 Payload payload = 3; 85 86 // Whether SimpleResponse should include username. 87 bool fill_username = 4; 88 89 // Whether SimpleResponse should include OAuth scope. 90 bool fill_oauth_scope = 5; 91 92 // Whether server should return a given status 93 EchoStatus response_status = 7; 94 95 // Whether SimpleResponse should include server_id. 96 bool fill_server_id = 9; 97 98 // Whether SimpleResponse should include grpclb_route_type. 99 bool fill_grpclb_route_type = 10; 100 } 101 102 // Unary response, as configured by the request. 103 message SimpleResponse { 104 // Payload to increase message size. 105 Payload payload = 1; 106 107 // The user the request came from, for verifying authentication was 108 // successful when the client expected it. 109 string username = 2; 110 111 // OAuth scope. 112 string oauth_scope = 3; 113 114 // Server ID. This must be unique among different server instances, 115 // but the same across all RPC's made to a particular server instance. 116 string server_id = 4; 117 118 // gRPCLB Path. 119 GrpclbRouteType grpclb_route_type = 5; 120 121 // Server hostname. 122 string hostname = 6; 123 } 124 125 // Client-streaming request. 126 message StreamingInputCallRequest { 127 // Optional input payload sent along with the request. 128 Payload payload = 1; 129 130 // Not expecting any payload from the response. 131 } 132 133 // Client-streaming response. 134 message StreamingInputCallResponse { 135 // Aggregated size of payloads received from the client. 136 int32 aggregated_payload_size = 1; 137 } 138 139 // Configuration for a particular response. 140 message ResponseParameters { 141 // Desired payload sizes in responses from the server. 142 // If response_type is COMPRESSABLE, this denotes the size before compression. 143 int32 size = 1; 144 145 // Desired interval between consecutive responses in the response stream in 146 // microseconds. 147 int32 interval_us = 2; 148 } 149 150 // Server-streaming request. 151 message StreamingOutputCallRequest { 152 // Desired payload type in the response from the server. 153 // If response_type is RANDOM, the payload from each response in the stream 154 // might be of different types. This is to simulate a mixed type of payload 155 // stream. 156 PayloadType response_type = 1; 157 158 // Configuration for each expected response message. 159 repeated ResponseParameters response_parameters = 2; 160 161 // Optional input payload sent along with the request. 162 Payload payload = 3; 163 164 // Whether server should return a given status 165 EchoStatus response_status = 7; 166 } 167 168 // Server-streaming response, as configured by the request and parameters. 169 message StreamingOutputCallResponse { 170 // Payload to increase response size. 171 Payload payload = 1; 172 } 173 174 // A simple service to test the various types of RPCs and experiment with 175 // performance with various types of payload. 176 service TestService { 177 // One empty request followed by one empty response. 178 rpc EmptyCall(google.protobuf.Empty) returns (google.protobuf.Empty); 179 180 // One request followed by one response. 181 // The server returns the client payload as-is. 182 rpc UnaryCall(SimpleRequest) returns (SimpleResponse); 183 184 // One request followed by a sequence of responses (streamed download). 185 // The server returns the payload with client desired type and sizes. 186 rpc StreamingOutputCall(StreamingOutputCallRequest) 187 returns (stream StreamingOutputCallResponse); 188 189 // A sequence of requests followed by one response (streamed upload). 190 // The server returns the aggregated size of client payload as the result. 191 rpc StreamingInputCall(stream StreamingInputCallRequest) 192 returns (StreamingInputCallResponse); 193 194 // A sequence of requests with each request served by the server immediately. 195 // As one request could lead to multiple responses, this interface 196 // demonstrates the idea of full duplexing. 197 rpc FullDuplexCall(stream StreamingOutputCallRequest) 198 returns (stream StreamingOutputCallResponse); 199 200 // A sequence of requests followed by a sequence of responses. 201 // The server buffers all the client requests and then serves them in order. A 202 // stream of responses are returned to the client when the server starts with 203 // first request. 204 rpc HalfDuplexCall(stream StreamingOutputCallRequest) 205 returns (stream StreamingOutputCallResponse); 206 } 207 208 // A simple service NOT implemented at servers so clients can test for 209 // that case. 210 service UnimplementedService { 211 // A call that no server should implement 212 rpc UnimplementedCall(google.protobuf.Empty) returns (google.protobuf.Empty); 213 } 214 215 message LoadBalancerStatsRequest { 216 // Request stats for the next num_rpcs sent by client. 217 int32 num_rpcs = 1; 218 // If num_rpcs have not completed within timeout_sec, return partial results. 219 int32 timeout_sec = 2; 220 } 221 222 message LoadBalancerStatsResponse { 223 // The number of completed RPCs for each peer. 224 map<string, int32> rpcs_by_peer = 1; 225 // The number of RPCs that failed to record a remote peer. 226 int32 num_failures = 2; 227 } 228 229 // A service used to obtain stats for verifying LB behavior. 230 service LoadBalancerStatsService { 231 // Gets the backend distribution for RPCs sent by a test client. 232 rpc GetClientStats(LoadBalancerStatsRequest) 233 returns (LoadBalancerStatsResponse) {} 234 }