You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So in the buf model you use buf to build everything, including the file descriptor sets (usually). But how you access the well known types was a bit of a mystery to me until I did some digging. In short you need to add the protoc-wkt crate and then use the file descriptor set like this:
use protoc_wkt::google::protobuf::{FILE_DESCRIPTOR_SET as GOOGLE_PROTOBUF_FILE_DESCRIPTOR_SET};
fn myfunc() {
let reflection_service = tonic_reflection::server::Builder::configure()
// Note: It is critical that the file descriptor set is registered for every
// file that the API proto depends on recursively. If you don't, compilation
// will still succeed but reflection will fail at runtime.
//
// TODO: Add a test for this / something in build.rs, this is a big footgun.
.register_encoded_file_descriptor_set(API_V2_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(TRANSACTION_V1_TESTING_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(UTIL_TIMESTAMP_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(GOOGLE_API_V1_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(GOOGLE_PROTOBUF_FILE_DESCRIPTOR_SET)
.build()
.context("Failed to build reflection service")?;
}
It'd be great to have an example that demonstrates how to use them. If I get some time any time soon I can take a crack at doing it myself 🤠
The text was updated successfully, but these errors were encountered:
I'm trying to setup the reflection service and it sure has been a pain to figure out where to get all the file descriptors.
In fact, I'm not sure how to get GOOGLE_API_V1_FILE_DESCRIPTOR_SET? Do I have to use --include-imports? In our case, we also use the protoc-gen-openapiv2 annotations and we're seeing reflection errors due to that.
While I appreciate protoc-gen-prost's approach to generating the FILE_DESCRIPTOR_SET, the default tonic-build approach does seem to make things slightly easier.
So in the buf model you use buf to build everything, including the file descriptor sets (usually). But how you access the well known types was a bit of a mystery to me until I did some digging. In short you need to add the
protoc-wkt
crate and then use the file descriptor set like this:It'd be great to have an example that demonstrates how to use them. If I get some time any time soon I can take a crack at doing it myself 🤠
The text was updated successfully, but these errors were encountered: