Options to produce a Descriptors.FileDescriptor out of a proto files with dependencies #3819
Replies: 1 comment 1 reply
-
Hey there!
Though one.
Kind of, we do have a maven-plugin that does the dependency resolution, and the code can probably be extracted from there to the protobuf utilities library, for reference https://github.com/Apicurio/apicurio-registry/blob/main/utils/maven-plugin/src/main/java/io/apicurio/registry/maven/ProtobufDirectoryParser.java#L37.
I believe 2 is the way to go here (that's why we have the resolution on the maven-plugin :)). In the end, if you have a proto definition with a dependency and you want to produce messages/requests in the end you're going to need the dependency definition as well. That said, we recently discovered that we might have a bug resolving proto files with different packages, at least in runtime server (we're always talking about client-side operation from our perspective on this discussion), I'll keep you posted. |
Beta Was this translation helpful? Give feedback.
-
Hi @carlesarnal !
This question/discussion is related Hyperfoil/Hyperfoil#281, which requires to:
Our reference of user experience is analogous to https://ghz.sh/docs/example_config where the import paths are indeed a way to specify the additional proto files required to parse the main one ie
"proto"
in the mentioned documentation link.By searching and modifying the
apicurio-registry-protobuf-schema-utilities
module, I have found 2 (not completed yet) ways to achieve what i need:Descriptors.FileDescriptor toFileDescriptor(protoFileName, protoFileElement, dependencies)
which requires specifying all the dependencies upfront (including well known types), although obtained without caring of parsing order (via
ProtoParser.Companion.parse
), but is not correctly populating the services in the parsed file descriptor (seetestVertxGreeting
failure). The nice thing is thatDynamicSchema::init
automatically resolve the provided dependencies.loadSchema(packageName, fileName, schemaDefinition, deps)
in order to allowdeps
maps to be placed in different folders than the main proto file loaded, seetestProtoImportDifferentPackagesViaProtoFileToFileDescriptor
. This method seems to work fine with services definitions, but requires a full-fat map of dependencies, each in theDescriptors.FileDescriptor
form, which means with their dependencies fully resolved too, if any (assuming I would use the same util method of the "main" proto).If compared to
1.
this approach requires to implement my own dependencies resolution mechanism and ensure all the requiredDescriptors.FileDescriptor
to be parsed upfront in the right order.My questions are:
Beta Was this translation helpful? Give feedback.
All reactions