control.proto 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright 2024, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. syntax = "proto3";
  17. // A controllable service for testing.
  18. //
  19. // The control service has one RPC of each kind, the input to each RPC controls
  20. // the output.
  21. service Control {
  22. rpc Unary(ControlInput) returns (ControlOutput) {}
  23. rpc ServerStream(ControlInput) returns (stream ControlOutput) {}
  24. rpc ClientStream(stream ControlInput) returns (ControlOutput) {}
  25. rpc BidiStream(stream ControlInput) returns (stream ControlOutput) {}
  26. }
  27. message ControlInput {
  28. // Whether metadata should be echo'd back in the initial metadata.
  29. //
  30. // Ignored if the initial metadata has already been sent back to the
  31. // client.
  32. //
  33. // Each header field name in the request headers will be prefixed with
  34. // "echo-". For example the header field name "foo" will be returned
  35. // as "echo-foo. Note that semicolons aren't valid in HTTP header field
  36. // names (apart from pseudo headers). As such all semicolons should be
  37. // removed (":path" should become "echo-path").
  38. bool echo_metadata_in_headers = 1;
  39. // Parameters for response messages.
  40. PayloadParameters message_params = 2;
  41. // The number of response messages.
  42. int32 number_of_messages = 3;
  43. // The status code and message to use at the end of the RPC.
  44. //
  45. // If this is set then the RPC will be ended after `number_of_messages`
  46. // messages have been sent back to the client.
  47. RPCStatus status = 5;
  48. // Whether the response should be trailers only.
  49. //
  50. // Ignored unless it's set on the first message on the stream. When set
  51. // the RPC will be completed with a trailers-only response using the
  52. // status code and message from 'status'. The request metadata will be
  53. // included if 'echo_metadata_in_trailers' is set.
  54. //
  55. // If this is set then 'number_of_messages', 'message_params', and
  56. // 'echo_metadata_in_headers' are ignored.
  57. bool is_trailers_only = 6;
  58. // Whether metadata should be echo'd back in the trailing metadata.
  59. //
  60. // Ignored unless 'status' is set.
  61. //
  62. // Each header field name in the request headers will be prefixed with
  63. // "echo-". For example the header field name "foo" will be returned
  64. // as "echo-foo. Note that semicolons aren't valid in HTTP header field
  65. // names (apart from pseudo headers). As such all semicolons should be
  66. // removed (":path" should become "echo-path").
  67. bool echo_metadata_in_trailers = 4;
  68. }
  69. message RPCStatus {
  70. // Status code indicating the outcome of the RPC.
  71. StatusCode code = 1;
  72. // The message to include with the 'code' at the end of the RPC.
  73. string message = 2;
  74. }
  75. enum StatusCode {
  76. OK = 0;
  77. CANCELLED = 1;
  78. UNKNOWN = 2;
  79. INVALID_ARGUMENT = 3;
  80. DEADLINE_EXCEEDED = 4;
  81. NOT_FOUND = 5;
  82. ALREADY_EXISTS = 6;
  83. PERMISSION_DENIED = 7;
  84. RESOURCE_EXHAUSTED = 8;
  85. FAILED_PRECONDITION = 9;
  86. ABORTED = 10;
  87. OUT_OF_RANGE = 11;
  88. UNIMPLEMENTED = 12;
  89. INTERNAL = 13;
  90. UNAVAILABLE = 14;
  91. DATA_LOSS = 15;
  92. UNAUTHENTICATED = 16;
  93. }
  94. message PayloadParameters {
  95. // The number of bytes to put into the output payload.
  96. int32 size = 1;
  97. // The content to use in the payload. The value is truncated to an octet.
  98. uint32 content = 2;
  99. }
  100. message ControlOutput {
  101. bytes payload = 1;
  102. }