rls_config.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. // Copyright 2020 The 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.lookup.v1;
  16. import "google/protobuf/duration.proto";
  17. option go_package = "google.golang.org/grpc/lookup/grpc_lookup_v1";
  18. option java_multiple_files = true;
  19. option java_package = "io.grpc.lookup.v1";
  20. option java_outer_classname = "RlsConfigProto";
  21. // Extract a key based on a given name (e.g. header name or query parameter
  22. // name). The name must match one of the names listed in the "name" field. If
  23. // the "required_match" field is true, one of the specified names must be
  24. // present for the keybuilder to match.
  25. message NameMatcher {
  26. // The name that will be used in the RLS key_map to refer to this value.
  27. // If required_match is true, you may omit this field or set it to an empty
  28. // string, in which case the matcher will require a match, but won't update
  29. // the key_map.
  30. string key = 1;
  31. // Ordered list of names (headers or query parameter names) that can supply
  32. // this value; the first one with a non-empty value is used.
  33. repeated string names = 2;
  34. // If true, make this extraction required; the key builder will not match
  35. // if no value is found.
  36. bool required_match = 3;
  37. }
  38. // A GrpcKeyBuilder applies to a given gRPC service, name, and headers.
  39. message GrpcKeyBuilder {
  40. // To match, one of the given Name fields must match; the service and method
  41. // fields are specified as fixed strings. The service name is required and
  42. // includes the proto package name. The method name may be omitted, in
  43. // which case any method on the given service is matched.
  44. message Name {
  45. string service = 1;
  46. string method = 2;
  47. }
  48. repeated Name names = 1;
  49. // If you wish to include the host, service, or method names as keys in the
  50. // generated RouteLookupRequest, specify key names to use in the extra_keys
  51. // submessage. If a key name is empty, no key will be set for that value.
  52. // If this submessage is specified, the normal host/path fields will be left
  53. // unset in the RouteLookupRequest. We are deprecating host/path in the
  54. // RouteLookupRequest, so services should migrate to the ExtraKeys approach.
  55. message ExtraKeys {
  56. string host = 1;
  57. string service = 2;
  58. string method = 3;
  59. }
  60. ExtraKeys extra_keys = 3;
  61. // Extract keys from all listed headers.
  62. // For gRPC, it is an error to specify "required_match" on the NameMatcher
  63. // protos.
  64. repeated NameMatcher headers = 2;
  65. // You can optionally set one or more specific key/value pairs to be added to
  66. // the key_map. This can be useful to identify which builder built the key,
  67. // for example if you are suppressing the actual method, but need to
  68. // separately cache and request all the matched methods.
  69. map<string, string> constant_keys = 4;
  70. }
  71. // An HttpKeyBuilder applies to a given HTTP URL and headers.
  72. //
  73. // Path and host patterns use the matching syntax from gRPC transcoding to
  74. // extract named key/value pairs from the path and host components of the URL:
  75. // https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
  76. //
  77. // It is invalid to specify the same key name in multiple places in a pattern.
  78. //
  79. // For a service where the project id can be expressed either as a subdomain or
  80. // in the path, separate HttpKeyBuilders must be used:
  81. // host_pattern: 'example.com' path_pattern: '/{id}/{object}/**'
  82. // host_pattern: '{id}.example.com' path_pattern: '/{object}/**'
  83. // If the host is exactly 'example.com', the first path segment will be used as
  84. // the id and the second segment as the object. If the host has a subdomain, the
  85. // subdomain will be used as the id and the first segment as the object. If
  86. // neither pattern matches, no keys will be extracted.
  87. message HttpKeyBuilder {
  88. // host_pattern is an ordered list of host template patterns for the desired
  89. // value. If any host_pattern values are specified, then at least one must
  90. // match, and the last one wins and sets any specified variables. A host
  91. // consists of labels separated by dots. Each label is matched against the
  92. // label in the pattern as follows:
  93. // - "*": Matches any single label.
  94. // - "**": Matches zero or more labels (first or last part of host only).
  95. // - "{<name>=...}": One or more label capture, where "..." can be any
  96. // template that does not include a capture.
  97. // - "{<name>}": A single label capture. Identical to {<name>=*}.
  98. //
  99. // Examples:
  100. // - "example.com": Only applies to the exact host example.com.
  101. // - "*.example.com": Matches subdomains of example.com.
  102. // - "**.example.com": matches example.com, and all levels of subdomains.
  103. // - "{project}.example.com": Extracts the third level subdomain.
  104. // - "{project=**}.example.com": Extracts the third level+ subdomains.
  105. // - "{project=**}": Extracts the entire host.
  106. repeated string host_patterns = 1;
  107. // path_pattern is an ordered list of path template patterns for the desired
  108. // value. If any path_pattern values are specified, then at least one must
  109. // match, and the last one wins and sets any specified variables. A path
  110. // consists of segments separated by slashes. Each segment is matched against
  111. // the segment in the pattern as follows:
  112. // - "*": Matches any single segment.
  113. // - "**": Matches zero or more segments (first or last part of path only).
  114. // - "{<name>=...}": One or more segment capture, where "..." can be any
  115. // template that does not include a capture.
  116. // - "{<name>}": A single segment capture. Identical to {<name>=*}.
  117. // A custom method may also be specified by appending ":" and the custom
  118. // method name or "*" to indicate any custom method (including no custom
  119. // method). For example, "/*/projects/{project_id}/**:*" extracts
  120. // `{project_id}` for any version, resource and custom method that includes
  121. // it. By default, any custom method will be matched.
  122. //
  123. // Examples:
  124. // - "/v1/{name=messages/*}": extracts a name like "messages/12345".
  125. // - "/v1/messages/{message_id}": extracts a message_id like "12345".
  126. // - "/v1/users/{user_id}/messages/{message_id}": extracts two key values.
  127. repeated string path_patterns = 2;
  128. // List of query parameter names to try to match.
  129. // For example: ["parent", "name", "resource.name"]
  130. // We extract all the specified query_parameters (case-sensitively). If any
  131. // are marked as "required_match" and are not present, this keybuilder fails
  132. // to match. If a given parameter appears multiple times (?foo=a&foo=b) we
  133. // will report it as a comma-separated string (foo=a,b).
  134. repeated NameMatcher query_parameters = 3;
  135. // List of headers to try to match.
  136. // We extract all the specified header values (case-insensitively). If any
  137. // are marked as "required_match" and are not present, this keybuilder fails
  138. // to match. If a given header appears multiple times in the request we will
  139. // report it as a comma-separated string, in standard HTTP fashion.
  140. repeated NameMatcher headers = 4;
  141. // You can optionally set one or more specific key/value pairs to be added to
  142. // the key_map. This can be useful to identify which builder built the key,
  143. // for example if you are suppressing a lot of information from the URL, but
  144. // need to separately cache and request URLs with that content.
  145. map<string, string> constant_keys = 5;
  146. }
  147. message RouteLookupConfig {
  148. // Ordered specifications for constructing keys for HTTP requests. Last
  149. // match wins. If no HttpKeyBuilder matches, an empty key_map will be sent to
  150. // the lookup service; it should likely reply with a global default route
  151. // and raise an alert.
  152. repeated HttpKeyBuilder http_keybuilders = 1;
  153. // Unordered specifications for constructing keys for gRPC requests. All
  154. // GrpcKeyBuilders on this list must have unique "name" fields so that the
  155. // client is free to prebuild a hash map keyed by name. If no GrpcKeyBuilder
  156. // matches, an empty key_map will be sent to the lookup service; it should
  157. // likely reply with a global default route and raise an alert.
  158. repeated GrpcKeyBuilder grpc_keybuilders = 2;
  159. // The name of the lookup service as a gRPC URI. Typically, this will be
  160. // a subdomain of the target, such as "lookup.datastore.googleapis.com".
  161. string lookup_service = 3;
  162. // Configure a timeout value for lookup service requests.
  163. // Defaults to 10 seconds if not specified.
  164. google.protobuf.Duration lookup_service_timeout = 4;
  165. // How long are responses valid for (like HTTP Cache-Control).
  166. // If omitted or zero, the longest valid cache time is used.
  167. // This value is clamped to 5 minutes to avoid unflushable bad responses.
  168. google.protobuf.Duration max_age = 5;
  169. // After a response has been in the client cache for this amount of time
  170. // and is re-requested, start an asynchronous RPC to re-validate it.
  171. // This value should be less than max_age by at least the length of a
  172. // typical RTT to the Route Lookup Service to fully mask the RTT latency.
  173. // If omitted, keys are only re-requested after they have expired.
  174. google.protobuf.Duration stale_age = 6;
  175. // Rough indicator of amount of memory to use for the client cache. Some of
  176. // the data structure overhead is not accounted for, so actual memory consumed
  177. // will be somewhat greater than this value. If this field is omitted or set
  178. // to zero, a client default will be used. The value may be capped to a lower
  179. // amount based on client configuration.
  180. int64 cache_size_bytes = 7;
  181. // This is a list of all the possible targets that can be returned by the
  182. // lookup service. If a target not on this list is returned, it will be
  183. // treated the same as an unhealthy target.
  184. repeated string valid_targets = 8;
  185. // This value provides a default target to use if needed. If set, it will be
  186. // used if RLS returns an error, times out, or returns an invalid response.
  187. // Note that requests can be routed only to a subdomain of the original
  188. // target, e.g. "us_east_1.cloudbigtable.googleapis.com".
  189. string default_target = 9;
  190. reserved 10;
  191. reserved "request_processing_strategy";
  192. }
  193. // RouteLookupClusterSpecifier is used in xDS to represent a cluster specifier
  194. // plugin for RLS.
  195. message RouteLookupClusterSpecifier {
  196. // The RLS config for this cluster specifier plugin instance.
  197. RouteLookupConfig route_lookup_config = 1;
  198. }