Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

adjust to java8 api#1060

Merged
RayRoestenburg merged 4 commits into
lightbend:mainfrom
michael-read:mread-fix-java8-grpc-example
Jul 20, 2021
Merged

adjust to java8 api#1060
RayRoestenburg merged 4 commits into
lightbend:mainfrom
michael-read:mread-fix-java8-grpc-example

Conversation

@michael-read

@michael-read michael-read commented May 28, 2021

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

The sample needed these changes so that it could compile on Java 8.

Why are the changes needed?

Sample was written using Java API > v8

Does this PR introduce any user-facing change?

No

How was this patch tested?

sbt runLocal, and sent data via grpcurl -plaintext -d '{"payload":"foo-bar"}' localhost:3000 sensordata.SensorDataService.Provide

@lightbend-cla-validator

Copy link
Copy Markdown
Collaborator

Hi @michael-read,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

https://www.lightbend.com/contribute/cla

import cloudflow.streamlets.StreamletShape;
import cloudflow.streamlets.proto.javadsl.ProtoInlet;

import scala.None;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes Ray, I missed that to optimize imports. Pushed a new update.

@RayRoestenburg

Copy link
Copy Markdown
Contributor

@RayRoestenburg test

SensorData.class,
true
true,
(inBytes, throwable) -> null

@RayRoestenburg RayRoestenburg Jun 14, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@michael-read Did you add this just to skip and not log?
The Java API has a ProtoInlet.create method (I would suggest to use that instead), though it does not have an option to provide the error handler (in case it is important to you not to log but to skip).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is now a Java API ProtoInlet.create that takes a errorHandler: (Array[Byte], Throwable) => Optional[T] would be nice if you used that instead of returning null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, I was just skipping it. I'm happy to add a log, if it'll make it better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

how about now @RayRoestenburg ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry missed this comment.
Can you return an Optional instead and use the Java API (ProtoInlet.create)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@RayRoestenburg so no ProtoOutlet.create?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only noticed this now, yes we should add that too to be consistent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a ProtoInlet.create that takes a (Array[Byte], Throwable) => Optional[T]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm totally lost on this. I don't see the API you're referring to in current. These are the two creates I can see in the API:

static <T extends com.google.protobuf.GeneratedMessageV3>ProtoInlet<T> | create(java.lang.String name, java.lang.Class<T> clazz)
-- | --
static <T extends com.google.protobuf.GeneratedMessageV3>ProtoInlet<T> | create(java.lang.String name, java.lang.Class<T> clazz, boolean hasUniqueGroupId)

So without the .withErrorHandler I'm at a lost. Sorry.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@RayRoestenburg

Copy link
Copy Markdown
Contributor

FYI @michael-read I've added a Java API for ProtoInlet for the errorHandler which uses Java Optional: #1066

@RayRoestenburg

RayRoestenburg commented Jul 15, 2021 via email

Copy link
Copy Markdown
Contributor

@RayRoestenburg

Copy link
Copy Markdown
Contributor

@michael-read sorry for the late reply, but I think I can see what is going on here, you have not updated your fork, which is why you don't see the code.
This branch is 4 commits ahead, 10 commits behind lightbend:main.
Instead of more back and forth, I'll merge this and then fix on top.

@RayRoestenburg RayRoestenburg merged commit ac2b7e6 into lightbend:main Jul 20, 2021
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.

4 participants