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

Add socket timeout configuration in gRPC client and server #12845

Merged
merged 6 commits into from
Dec 20, 2018

Conversation

daneshk
Copy link
Member

@daneshk daneshk commented Dec 19, 2018

Purpose

Resolves #11276

@codecov-io
Copy link

codecov-io commented Dec 19, 2018

Codecov Report

❗ No coverage uploaded for pull request base (release-0.990.0@f63c590). Click here to learn what that means.
The diff coverage is 65.62%.

Impacted file tree graph

@@                Coverage Diff                 @@
##             release-0.990.0   #12845   +/-   ##
==================================================
  Coverage                   ?   60.02%           
  Complexity                 ?      659           
==================================================
  Files                      ?     2068           
  Lines                      ?   101681           
  Branches                   ?    12936           
==================================================
  Hits                       ?    61030           
  Misses                     ?    35477           
  Partials                   ?     5174
Impacted Files Coverage Δ Complexity Δ
...java/org/ballerinalang/net/grpc/GrpcConstants.java 100% <ø> (ø) 0 <0> (?)
...a/org/ballerinalang/net/grpc/ProtoInputStream.java 22.91% <ø> (ø) 0 <0> (?)
...in/java/org/ballerinalang/net/grpc/ClientCall.java 46.82% <0%> (ø) 0 <0> (?)
...lang/net/grpc/nativeimpl/serviceendpoint/Init.java 74.04% <50%> (ø) 0 <0> (?)
...alang/net/grpc/nativeimpl/clientendpoint/Init.java 81.57% <62.5%> (ø) 0 <0> (?)
...va/org/ballerinalang/net/grpc/MessageDeframer.java 67.24% <77.77%> (ø) 0 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f63c590...1fca349. Read the comment docs.

}
long timeoutMillis = clientEndpointConfig.getIntField(CLIENT_EP_ENDPOINT_TIMEOUT);
if (timeoutMillis < 0 || !isInteger(timeoutMillis)) {
throw new BallerinaConnectorException("invalid idle timeout: " + timeoutMillis);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of throwing a runtime exception what if we say that if it is <=0 then we are disabling the idleTimeout and if it is not an integer we log a warning and set it to Integer.MaxValue. This is because it would prevent the application crashing just because the user made a mistake of using large value (which is actually allowed in Ballerina) This is how we have done in WebSocket.

Copy link
Member Author

Choose a reason for hiding this comment

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

Current gRPC implementation, we throw exception for any invalid user input. If we are going with default for invalid user input, we need to change all places where applied. I will review it make the change later. For now shall we keep this to maintain consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it is best to avoid crashing the app as much as possible. +1 for doing it in a different PR.

@@ -185,7 +186,8 @@ public void sendMessage(Message message) {
try {
InputStream resp = method.streamRequest(message);
outboundMessage.sendMessage(resp);

} catch (StatusRuntimeException ex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need to catch this if we don't do anything? Since this is a RuntimeException shall we leave without handling it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Earlier for any exception we throw StatusRuntimeException and we need to avoid reconstructing exception if it is StatusRuntimeException.

@daneshk daneshk merged commit 109004c into ballerina-platform:release-0.990.0 Dec 20, 2018
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.

4 participants