-
Notifications
You must be signed in to change notification settings - Fork 182
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
[grpc-protoc] Add an option to generate default service methods #3110
[grpc-protoc] Add an option to generate default service methods #3110
Conversation
...ns/src/main/java/io/servicetalk/examples/grpc/protocoptions/BlockingProtocOptionsServer.java
Show resolved
Hide resolved
servicetalk-examples/grpc/protoc-options/src/main/proto/test_service.proto
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Main.java
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
…d code (apple#3089) ### Motivation The generated ServiceTalk gRPC stubs make use of deprecated calls. This causes a problem when `-Werror` is used to build the code since it will automatically fail the build. We should allow users who have already migrated their code to prevent the protoc compiler from generating and using deprecated references. ### Modifications Add an option, `skipDeprecated`, as part of the protoc compiler configuration, to tell the generator to leave out deprecated references. Remove - initSerializationProvider, reason: ContentCodec is deprecated - isSupportedMessageCodingsEmpty, reason ContentCodec is deprecated - Deprecated ServiceFactory constructors - ServiceFactory::Builder references to ContentCodec - Generated client metadata and associated methods, reason: deprecated ### Result Users can generate gRPC stubs without deprecated code. ### Testing Manually tested: - Add new option to ServiceTalk/examples/grpc/protoc-options and use it to generate test_service.proto which covers all combinations of streaming (or not) services.
d8de863
to
7ed1fe5
Compare
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.
New findings:
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Show resolved
Hide resolved
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.
Take my review with a grain of salt, but it seems good to me.
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-protoc/src/main/java/io/servicetalk/grpc/protoc/Generator.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/test/java/io/servicetalk/grpc/netty/ProtocolCompatibilityTest.java
Outdated
Show resolved
Hide resolved
servicetalk-grpc-netty/src/test/java/io/servicetalk/grpc/netty/ProtocolCompatibilityTest.java
Outdated
Show resolved
Hide resolved
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.
Pushed minor style corrections into your branch: 80b53a4
Everything looks good, great work!
Motivation
When evolving a service definition that has multiple implementations it is ideal not to break these implementations. Therefore it would be nice if the protoc generator was able to generate default implementations on the service interface to ensure implementations always conform.
Changes
Add an option,
defaultServiceMethods
to the grpc-protoc stub compiler to generate these default implementation. The result is that service interfaces will provide a default, throwing, implementation of all service RPC interfaces that they implement.test_service.proto: https://gist.github.com/mgodave/d9064c67da9f365de70ef7526c9eea72