api/config: use resource type annotations to provide type-to-endpoint. (#9566)
Previously, type_to_endpoint.cc had a lot of hardcoding, which doesn't scale well with multiple API versions. See https://github.com/envoyproxy/envoy/pull/9526 for an example of the issues encountered. This patch switches to using explicit resource type annotations on service descriptors, which is great for documentation (previously this was sometimes given in comments, sometimes not), and allows for a reflection driven reverse map from resource type URL to endpoints to be built at runtime. Risk level: Low Testing: New unit tests for type_to_endpoint.cc and golden protoxform tests for the new annotations. Fixes #9454. Signed-off-by: Harvey Tuch <htuch@google.com> Mirrored from https://github.com/envoyproxy/envoy @ cceab393664429a3063d787cf28cade3c8ab01c7master-ci-test
parent
47d665dff3
commit
abba11d3ee
25 changed files with 79 additions and 19 deletions
@ -0,0 +1,5 @@ |
||||
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") |
||||
|
||||
licenses(["notice"]) # Apache 2 |
||||
|
||||
api_proto_package() |
@ -0,0 +1,16 @@ |
||||
syntax = "proto3"; |
||||
|
||||
package envoy.annotations; |
||||
|
||||
import "google/protobuf/descriptor.proto"; |
||||
|
||||
// Magic number in this file derived from top 28bit of SHA256 digest of "envoy.annotation.resource". |
||||
extend google.protobuf.ServiceOptions { |
||||
ResourceAnnotation resource = 265073217; |
||||
} |
||||
|
||||
message ResourceAnnotation { |
||||
// Annotation for xDS services that indicates the fully-qualified Protobuf type for the resource |
||||
// type. |
||||
string type = 1; |
||||
} |
Loading…
Reference in new issue