grpc/xds: Add feature-gated xDS proto codegen and the generated .rs code#2723
grpc/xds: Add feature-gated xDS proto codegen and the generated .rs code#2723gu0keno0 wants to merge 7 commits into
Conversation
|
I've been poking at this today on my computer, trying to understand what protobuf is doing and trying to understand our options. Some notes that don't impact the heart of the PR too much:
I had thought (2) is what we said would be best during our meeting. @dfawley can confirm. (I'll be on vacation tomorrow.) At this point I think I see why you've made the various choices you did. I think I agree that is at least close to optimal right now. But I think we'd also all agree this is ridiculous. I want to think more about what we can suggest to protobuf to make the situation better. I feel we'll be doing everyone a disservice if we don't figure out a better approach before protobuf stabilizes. (I don't yet see a reason protoc is run per-file instead of per-directory/proto-package. I'm right now assuming both ways would work and you just chose something and went with it.) |
|
Thanks for looking. Answer the questions inline.
In #2728 @dfawley is suggesting to put the generated code into a separate crate grpc-xds. I think build.rs makes sense. For Envoy go-control-plaine and java-control-plane, they have to check in generated code because they don't have build.rs . For Rust it's not a problem.
The per-file approach is because there are naming conflicts. If we feed all of them directly into protoc, the generated code will have naming conflicts under the same flattened namespace (5000+ errors), because in generated code, the proto types are re-exported by a statement like "pub use internal_do_not_use_:: re-export." and there are the name conflicts such as "Policy" and "Filter". The per-file approach creates a module wrapper for each file, and therefore eliminates the name collisions. I think this shenanigan will go away if Protobuf natively support organizing the generated code by protobuf package modules (similar to this PR but natively supported by protoc). |
Add xds protos, codegen and generated .rs files
Motivation
The usual places for the generated code of xDS protobuf is https://github.com/envoyproxy, e.g. https://github.com/envoyproxy/go-control-plane. However, currently there's no official https://github.com/envoyproxy/rust-control-plane.
For gRPC, we need to use the Google protobuf codegen to generate the xDS structs, therefore created this PR to do the job.
Solution
Test Plan