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

scalapb-runtime-grpc: optimize Marshaller for InProcessTransport #1615

Merged
merged 6 commits into from
Dec 1, 2023

Conversation

hugebdu
Copy link
Contributor

@hugebdu hugebdu commented Nov 28, 2023

resolves #1614

* Allows skipping serialization completely when the io.grpc.inprocess.InProcessTransport is used.
* Inspired by https://github.com/grpc/grpc-java/blob/master/protobuf-lite/src/main/java/io/grpc/protobuf/lite/ProtoInputStream.java
*/
class ProtoInputStream[T <: GeneratedMessage](msg: T, val marshaller: Marshaller[T]) extends InputStream {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add unit tests for this class?

Copy link
Contributor Author

@hugebdu hugebdu Nov 29, 2023

Choose a reason for hiding this comment

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

added in 6c26c6a

override def parse(inputStream: InputStream): T =
companion.parseFrom(inputStream)
override def parse(inputStream: InputStream): T = inputStream match {
case pis: ProtoInputStream[T] if pis.marshaller == this => pis.message
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the reason for comparing the marshallers? if not needed, the val marshaller can be removed from the ProtoInputStream class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in 8d8256c

introduced it to reproduce the following precaution logic, however seems to be redundant indeed.

@@ -60,6 +60,7 @@ object Dependencies {
val grpcNetty = "io.grpc" % "grpc-netty" % versions.grpc
val grpcServices = "io.grpc" % "grpc-services" % versions.grpc
val grpcProtocGen = "io.grpc" % "protoc-gen-grpc-java" % versions.grpc
val grpcInprocess = "io.grpc" % "grpc-inprocess" % versions.grpc
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: align the whitespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thesamet
Copy link
Contributor

LGTM, all tests are passing except formatting. Please run scalafmt within sbt and add to the PR as a new commit.

@hugebdu
Copy link
Contributor Author

hugebdu commented Nov 30, 2023

@thesamet formatted the code in 1aa83f1

thanks!

@thesamet thesamet merged commit 427db01 into scalapb:master Dec 1, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scalapb grpc runtime & InProcessTransport
3 participants