-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Feature request: Provide a way to make sure that their code does not break when services add new rpcs. #2318
Comments
(Context: This came up in #2313.) https://github.com/grpc/grpc-go/tree/master/health/grpc_health_v1 package just made a change (because health.proto in grpc_health_v1 package in grpc-go v1.14.0 had:
so I implemented this interface in my code. Then I updated my
as expected, having not implementing this |
Your proposal works, and might be the best short-term solution. Two downsides: 1. compile-time type safety is effectively lost (if the user typos a method name, everything still compiles), and 2. we can't force users to do this, and users that don't will break when new RPCs are added to services. An alternative would be to support registering methods one-by-one and recommend using that instead of service-level registration. The implementation of |
The solution inside Google is that the stubby codegen creates an |
If this is still open, I would like to get assigned to it. @dsymonds solution seems doable. |
@prannayk - Sounds good to me, thanks! The grpc code gen lives in the proto repo - let me know if you need any help with that, and please cc me on any PRs you send there. |
I've made a separate proto plugin that solves this: https://github.com/srikrsna/protoc-gen-defaults |
Fixed by golang/protobuf#785 |
When a gRPC service is defined in a proto a corresponding interface is generated. A user is expected to implement this interface.
When the proto is updated to add a new API method, the interface generated changes.
Any struct that implements that interface is no longer in conformance. Therefore, the code breaks.
I would expect the structs to be forward compatible.
This can potentially be solved by the code generating a dummy struct that implements the interface. Users can then embed that struct and only implement the methods they care about, effectively overriding the default methods.
The text was updated successfully, but these errors were encountered: