Skip to content
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: Ensure that code does not break when services add new RPCs. #784

Closed
prannayk opened this issue Jan 15, 2019 · 2 comments
Closed

Comments

@prannayk
Copy link
Contributor

Imported from: grpc/grpc-go#2318 as-is.

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.

Solution proposed by : @dfawley @dsymonds
The solution inside Google is that the stubby codegen creates an UnimplementedFooService concrete type that implements the interface with methods that return an unimplemented error. Servers that wish to avoid breaking when the Foo service is extended can embed that type in their own implementation, and new methods will thus transparently work (by returning that unimplemented error). That's effectively what the OP suggests, and it seems to work well enough in practice.

@prannayk prannayk changed the title Feature request: Provide a way to make sure that their code does not break when services add new rpcs. Feature request: Provide a way to make sure that code does not break when services add new rpcs. Jan 15, 2019
@prannayk prannayk changed the title Feature request: Provide a way to make sure that code does not break when services add new rpcs. Feature Request: Ensure that code does not break when services add new RPCs. Jan 15, 2019
@srikrsna
Copy link

I was not sure whether it can be a part of this repo hence I made this: https://github.com/srikrsna/protoc-gen-defaults

@dsnet
Copy link
Member

dsnet commented Jun 6, 2019

Closing as resolved via #785.

@dsnet dsnet closed this as completed Jun 6, 2019
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants