Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "grpc"
version = "1.14.3"
version = "1.14.4"
distribution = "2201.12.0"
authors = ["Ballerina"]
keywords = ["network", "grpc", "protobuf", "server-streaming", "client-streaming", "bidirectional-streaming"]
Expand All @@ -16,11 +16,11 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "grpc-native"
version = "1.14.3"
path = "../native/build/libs/grpc-native-1.14.3.jar"
version = "1.14.4"
path = "../native/build/libs/grpc-native-1.14.4-SNAPSHOT.jar"

[[platform.java21.dependency]]
path = "../test-utils/build/libs/grpc-test-utils-1.14.3.jar"
path = "../test-utils/build/libs/grpc-test-utils-1.14.4-SNAPSHOT.jar"
scope = "testOnly"

[[platform.java21.dependency]]
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "grpc-compiler-plugin"
class = "io.ballerina.stdlib.grpc.plugin.GrpcCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/grpc-compiler-plugin-1.14.3.jar"
path = "../compiler-plugin/build/libs/grpc-compiler-plugin-1.14.4-SNAPSHOT.jar"
6 changes: 3 additions & 3 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "crypto"
version = "2.9.2"
version = "2.9.3"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand Down Expand Up @@ -78,7 +78,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "grpc"
version = "1.14.3"
version = "1.14.4"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -302,7 +302,7 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.5.0"
version = "1.5.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
11 changes: 11 additions & 0 deletions native/src/main/java/io/ballerina/stdlib/grpc/GrpcUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ private GrpcUtil() {

private static final Logger log = LoggerFactory.getLogger(GrpcUtil.class);

private static final int BUFFER_SIZE = 1048576;
private static final int BACK_LOG = 100;

public static ConnectionManager getConnectionManager(BMap<BString, Long> poolStruct) {

ConnectionManager poolManager = (ConnectionManager) poolStruct.getNativeData(CONNECTION_MANAGER);
Expand Down Expand Up @@ -233,6 +236,8 @@ public static ListenerConfiguration getListenerConfig(long port, BMap endpointCo
listenerConfiguration.setServerHeader(getServerName());
}

setSocketConfig(listenerConfiguration);

if (sslConfig != null) {
return setSslConfig(sslConfig, listenerConfiguration);
}
Expand All @@ -246,6 +251,12 @@ public static ListenerConfiguration getListenerConfig(long port, BMap endpointCo
return listenerConfiguration;
}

private static void setSocketConfig(ListenerConfiguration listenerConfiguration) {
listenerConfiguration.setReceiveBufferSize(BUFFER_SIZE);
listenerConfiguration.setSendBufferSize(BUFFER_SIZE);
listenerConfiguration.setSoBackLog(BACK_LOG);
}

private static String getServerName() {

String userAgent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static Object startServerConnector(BObject listener, ServicesRegistry se
try {
serverConnectorFuture.sync();
} catch (Exception ex) {
return MessageUtils.getConnectorError(new StatusRuntimeException(Status
throw MessageUtils.getConnectorError(new StatusRuntimeException(Status
Copy link
Member

Choose a reason for hiding this comment

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

Is there any specific reason to throw here instead of return similar to other places?

Copy link
Member Author

Choose a reason for hiding this comment

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

When the backend server had an error at startup, return was treated as a normal exit rather than an error exit. The grpc build was passing, though tests were not run properly.

.fromCode(Status.Code.INTERNAL.toStatus().getCode()).withDescription(
"Failed to start server connector '" + serverConnector.getConnectorID()
+ "'. " + ex.getMessage())));
Expand Down Expand Up @@ -192,9 +192,15 @@ public static Object externStart(BObject listener) {
*/
public static Object gracefulStop(BObject serverEndpoint) {

getServerConnector(serverEndpoint).stop();
serverEndpoint.addNativeData(GrpcConstants.CONNECTOR_STARTED, false);
return null;
try {
getServerConnector(serverEndpoint).stop();
serverEndpoint.addNativeData(GrpcConstants.CONNECTOR_STARTED, false);
return null;
} catch (Exception ex) {
return MessageUtils.getConnectorError(new StatusRuntimeException(Status
.fromCode(Status.Code.INTERNAL.toStatus().getCode()).withDescription(
"Failed to stop server connector gracefully. " + ex.getMessage())));
}
}

/**
Expand All @@ -204,9 +210,16 @@ public static Object gracefulStop(BObject serverEndpoint) {
* @return Error if there is an error while stopping the server, else returns nil.
*/
public static Object immediateStop(BObject serverEndpoint) {
getServerConnector(serverEndpoint).immediateStop();
serverEndpoint.addNativeData(GrpcConstants.CONNECTOR_STARTED, false);
return null;

try {
getServerConnector(serverEndpoint).immediateStop();
serverEndpoint.addNativeData(GrpcConstants.CONNECTOR_STARTED, false);
return null;
} catch (Exception ex) {
return MessageUtils.getConnectorError(new StatusRuntimeException(Status
.fromCode(Status.Code.INTERNAL.toStatus().getCode()).withDescription(
"Failed to stop server connector immediately. " + ex.getMessage())));
}
}

public static Object nextResult(Environment env, BObject streamIterator) {
Expand Down