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

compiler: Generate interfaces for services to implement #9688

Merged
merged 43 commits into from
Feb 15, 2023

Conversation

larry-safran
Copy link
Contributor

@larry-safran larry-safran commented Nov 12, 2022

When generating Java code from an rpc proto, not only generate the ImplBase and stub methods, but also generate an interface named AsyncService containing the async service methods and have the <service>ImplBase classes implement it in addition to BindableService.

All methods for the interfaces are defined with defaults.
The current logic for the methods in <service>ImplBase will be moved to the default methods ofAsyncService and the methods will be removed from <service>ImplBase.

The bindService logic will be moved into the main Grpc class in a method with the signature:
public static final io.grpc.ServerServiceDefinition bindService(<service>Async serviceImpl)
fixes #9320

@ejona86
Copy link
Member

ejona86 commented Nov 14, 2022

We do not want the client stubs to implement the interfaces; they are final today to prevent mocking.

@larry-safran larry-safran self-assigned this Nov 14, 2022
@larry-safran
Copy link
Contributor Author

@ejona86 Ready for rereview.

@larry-safran
Copy link
Contributor Author

@ejona86 ping

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still going through it. Sending what I have.

compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We need to check if the ExperimentalApi annotations will compile cleanly with grpc-java-api-checker.

.gitignore Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
compiler/src/java_plugin/cpp/java_generator.cpp Outdated Show resolved Hide resolved
@larry-safran larry-safran added the kokoro:force-run Add this label to a PR to tell Kokoro to re-run all tests. Not generally necessary label Feb 14, 2023
@grpc-kokoro grpc-kokoro removed the kokoro:force-run Add this label to a PR to tell Kokoro to re-run all tests. Not generally necessary label Feb 14, 2023
@larry-safran larry-safran requested a review from ejona86 February 14, 2023 19:16
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated code looks good.

.gitignore Outdated Show resolved Hide resolved
@larry-safran larry-safran merged commit 19eab29 into grpc:master Feb 15, 2023
@larry-safran larry-safran deleted the service-interfaces branch February 15, 2023 18:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate interfaces for services to implement
3 participants