-
Notifications
You must be signed in to change notification settings - Fork 50
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
feat(internal/gengapic): move operations & iterators to aux.go #1428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple nits
// auxTypes gathers details of types we need to generate along with the client | ||
type auxTypes struct { | ||
// Map of RPC descriptor to assigned operationWrapper. | ||
methodToWrapper map[*descriptorpb.MethodDescriptorProto]operationWrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someday we should create a lightweight generic sorted map impl. We always be sorting in generator because of key randomness today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oo that would be great, and fun :)
If you want to, we could start one in this repo's internal package, then potentially give it its own repo? Would be good practice with generics...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments in this PR are great. They made it really easy to understand.
Also: Bravo on closing an issue from 2019! 🎉
I had one question about testing, super minor.
Ready to release this now. merging. |
🤖 I have created a release *beep* *boop* --- ## [0.39.0](https://togithub.com/googleapis/gapic-generator-go/compare/v0.38.2...v0.39.0) (2023-11-01) ### Features * **internal/gengapic:** Move operations & iterators to aux.go ([#1428](https://togithub.com/googleapis/gapic-generator-go/issues/1428)) ([e8ad272](https://togithub.com/googleapis/gapic-generator-go/commit/e8ad27239eca2cb09623812e1bb0bf88f5f7a5c1)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Generate all
Iterator
andOperation
wrapper types into a single file -aux.go
. The auxiliary types can be shared across the entire client package when certain criteria are met.For
Iterator
wrappers, it is simply a matching repeated type, common when multiple RPCs paginate over the same message.For
Operation
wrappers, the RPC name must be the same, as well as the response and metadata types declared inside of the operation returned. This is less common, but can happen if two proto services in the same package share an RPC name and types. This introduces a new generator error mode when the aforementioned conditions are not met. This is good because previously the generator would succeed, but the generated code would not compile (colliding type names) and not provide a clear reason to debug.The operation "builder" methods that are generated onto a service client type surface remain in the same place - in the service client file. These are specific to each client, even if they are mostly the same in surface between clients, so we keep them generated in the client file.
An example of the changes can be found in #8703. Building all Go gapic targets under google/cloud worked.
Note: Thus undoes #1398, which will result in a breaking change in the beta client it address a collision in. This is OK because the client is marked as beta/unstable, and it is more true to the surface.
Fixes #156.
Updates #1399.