-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow *.orion.pb.go files to be generated into a different package from the generated protobufs #186
Comments
Before we use the latest version of protoc-gen-go to get the exported service desc. We also have to introduce google.golang.org/grpc/cmd/protoc-gen-go-grpc into our protogen tool. Because it's separated from protoc-gen-go after v1.20.0. |
After protogen supports higher version. To call the exported service desc from *.orion.pb.go, we have to make protoc-gen-orion support to retrieve go_package from protobufs. The go_package provides the package import path of generated *.pb.go files. protoc-gen-orion can import the package with go_package to get the exported service desc.
|
Alright, the approach of having protoc-gen-orion read I'm thinking about how to make the changes backwards compatible too.
My proposal is:
With these two flags, our protoc command can be either: protoc --orion_out=. --orion_opt="exported-service-desc=true" --orion_opt="standalone-mode=true" source.proto
protoc --orion_out="exported-service-desc=true,standalone-mode=true:." source.proto What do you think? |
The flag designed in your proposal is good. |
How about having a v2 protoc-gen-orion. |
@benjaminheng Please check the PR. To make the changes smaller, the PR doesn't contain the versioning upgrading plan. We can have more discussion on the plan later. |
Currently the generated *.orion.pb.go file needs to be placed as a sibling to the generated protobufs, because the orion file references an unexported variable:
Orion/protoc-gen-orion/orion.go
Line 262 in ec021a7
In later versions of protoc-gen-go-grpc, this variable is now exported. #171 is a related issue to allow protoc-gen-orion to use the exported variable.
The variable being exported now also means that it should be possible to place the *.orion.pb.go file in a separate package. In Carousell we're considering having a Go module for all generated protobufs, and another module for all generated orion *.orion.pb.go files.
Ideally the module for generated protobufs will only contain two dependencies:
Having the orion files as a sibling will require
github.com/carousell/Orion
to be added as another dependency. The orion dependency is too heavy for us to include. Not every service that consumes our generated protobufs will need Orion.Thus ideally the orion file will live in a separate package. Example file structure:
I have some ideas of how to extend protoc-gen-orion to support this. I'll add more comments to the issue later.
The text was updated successfully, but these errors were encountered: