Is there a way to use types from external proto generation? #3286
Replies: 2 comments 1 reply
-
I'm assuming that "type" means the actual struct generated by protobuf - not the abstract shape of the data structure. Also I'm assuming "use" means the generated Goa code using these structs - not the user code (as obviously that can use anything). If these assumptions are correct then the short answer is no: the Goa generated code cannot directly use runtime structs that are defined in external packages. A couple of things that might help though:
|
Beta Was this translation helpful? Give feedback.
-
I came up with a possible work around by wrapping the external proto types in a new "user" type. I did this using the Meta function in the DSL with the I found some inconsistencies in the code generation this way that results in code that fails to compile. I made an example repo for reference to help reproduce the behavior. https://github.com/TomTardigradeSEL/goa-type-override The main issues are in the grpc client and server types.go files.
Responses to questions/suggestions:
Using the CreateFrom and ConvertTo functions don't work with grpc messages because they contain non-pointer nested structures (state, sizeCache, unknownFields). I included some commented out design DSL in the repo example.
Would the overriding here be dependent on being able to use the CreateFrom and ConvertTo? Some final thoughts. It would help for projects wanting to transition into using goa, if the Meta Thank you for the suggestions and response. |
Beta Was this translation helpful? Give feedback.
-
My team is incrementally adopting to Goa for our service design and definitions. We have existing services that use grpc and protobuf. Is there a way to directly use the existing types as payloads when writing the design.go files with the DSL?
Beta Was this translation helpful? Give feedback.
All reactions