github.com/bakjos/protoreflect@v1.9.2/internal/testprotos/grpc/test.proto (about)

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