-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit based on in-progress work from Tomas. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Additional work arounds tests and descriptors. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Simple unary method call without using stubs. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Basic support for unary, serverStream, streamClient and bidi invocations. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Support for sync and async gRPC calls. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Fixed problem with EOS and improved logging. All basic tests are passing. * Initial support for gRPC stubs, async only for now. * New test for gRPC that uses stubs. Fixes a number of checkstyle and copyright issues. * Use WebClient to create GrpcClient(s). * Fixed unary blocking test. * Support for TLS. Switched tests to use TLS. * Simplified and optimized implementation of gRPC unary calls. * Moved test to webclient module. * Removed currently unused types from grpc core module. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Cleanup of webserver gRPC module. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Test cleanup and copyright errors. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Adds support for setting up gRPC routes in tests. Updates gRPC tests to implement @SetupRoute methods. * Removes currently unused types. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * - Simplifies the grpc.core module to the bare minimum that is needed now - Cleans all module-info.java files - Switches to System.Logger for logging * Switches to socket context logging. Throws more detailed exception if baseUri is not present. * Converts PriorityBag to WeightedBag. Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> * Introduces support for client interceptors in low-level, stub-free API. * Basic support for client interceptors with service stubs * Improves support for empty server streams. Includes fix in Http2ClientStream to allow transitions from HEADERS to END. New tests. * Adds more tests for client and server empty streams. * Handles server EOS in HEADERS frame on the client side. Increased read timeout on client. * Some new tests from JK and fixes to gRPC client code to handle: (1) exceptions thrown in gRPC methods and (2) larger payloads. * Fixes problems in unary calls with large payloads. * Use protobuf version for protoc. Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com> * Basic support for gRPC protocol config settings * Javadoc updates. Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com> * Improves handling for server connection drops. On a read timeout, if the abort flag is not set, attempts to send a PING frame to verify the connection's health. * Uses a separate virtual thread to check if the connection to the server has died. The period to check for that is configurable and set to 5 seconds by default. * Sets heartbeat period to 0, thus disabling the feature by default. Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com> * Fixes logging message and test. * Refactors a few classes in grpc/core. Addresses other comments in PR review. * Reduces the number of logging statements in favor of using low-level HTTP/2 logging instead. Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com> * Some code reformatting using the Helidon scheme. Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com> --------- Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com> Signed-off-by: Santiago Pericas-Geertsen <santiago.pericasgeertsen@oracle.com>
- Loading branch information
Showing
66 changed files
with
4,674 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...server/protocols/src/main/java/io/helidon/examples/webserver/protocols/ProtocolsMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/webserver/protocols/src/main/resources/logging.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2018, 2024 Oracle and/or its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>helidon-grpc-project</artifactId> | ||
<groupId>io.helidon.grpc</groupId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>helidon-grpc-core</artifactId> | ||
<name>Helidon gRPC related modules</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.helidon.common</groupId> | ||
<artifactId>helidon-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.grpc</groupId> | ||
<artifactId>grpc-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.grpc</groupId> | ||
<artifactId>grpc-protobuf</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.protobuf</groupId> | ||
<artifactId>protobuf-java</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.grpc</groupId> | ||
<artifactId>grpc-stub</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.google.j2objc</groupId> | ||
<artifactId>j2objc-annotations</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
45 changes: 45 additions & 0 deletions
45
grpc/core/src/main/java/io/helidon/grpc/core/DefaultMarshallerSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.helidon.grpc.core; | ||
|
||
import com.google.protobuf.MessageLite; | ||
import io.grpc.MethodDescriptor; | ||
|
||
/** | ||
* The default {@link MarshallerSupplier}. | ||
*/ | ||
class DefaultMarshallerSupplier implements MarshallerSupplier { | ||
|
||
private DefaultMarshallerSupplier() { | ||
} | ||
|
||
static DefaultMarshallerSupplier create() { | ||
return new DefaultMarshallerSupplier(); | ||
} | ||
|
||
private final ProtoMarshallerSupplier proto = ProtoMarshallerSupplier.create(); | ||
|
||
@Override | ||
public <T> MethodDescriptor.Marshaller<T> get(Class<T> clazz) { | ||
if (MessageLite.class.isAssignableFrom(clazz)) { | ||
return proto.get(clazz); | ||
} | ||
String msg = String.format( | ||
"Class %s must be a valid ProtoBuf message, or a custom marshaller for it must be specified explicitly", | ||
clazz.getName()); | ||
throw new IllegalArgumentException(msg); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
grpc/core/src/main/java/io/helidon/grpc/core/InterceptorWeights.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.helidon.grpc.core; | ||
|
||
/** | ||
* gRPC interceptor weight classes. Higher weight means higher priority. | ||
*/ | ||
public class InterceptorWeights { | ||
|
||
/** | ||
* Context weight. | ||
* <p> | ||
* Interceptors with this weight typically <b>only</b> perform tasks | ||
* such as adding state to the call {@link io.grpc.Context}. | ||
*/ | ||
public static final int CONTEXT = 5000; | ||
|
||
/** | ||
* Tracing weight. | ||
* <p> | ||
* Tracing and metrics interceptors are typically applied after any context | ||
* interceptors so that they can trace and gather metrics on the whole call | ||
* stack of remaining interceptors. | ||
*/ | ||
public static final int TRACING = CONTEXT + 1; | ||
|
||
/** | ||
* Security authentication weight. | ||
*/ | ||
public static final int AUTHENTICATION = 2000; | ||
|
||
/** | ||
* Security authorization weight. | ||
*/ | ||
public static final int AUTHORIZATION = 2000; | ||
|
||
/** | ||
* User-level weight. | ||
* <p> | ||
* This value is also used as a default weight for application-supplied interceptors. | ||
*/ | ||
public static final int USER = 1000; | ||
|
||
/** | ||
* Cannot create instances. | ||
*/ | ||
private InterceptorWeights() { | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
grpc/core/src/main/java/io/helidon/grpc/core/MarshallerSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2019, 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.helidon.grpc.core; | ||
|
||
import io.grpc.MethodDescriptor; | ||
|
||
/** | ||
* A supplier of {@link MethodDescriptor.Marshaller} instances for specific | ||
* classes. | ||
*/ | ||
@FunctionalInterface | ||
public interface MarshallerSupplier { | ||
|
||
/** | ||
* Obtain a {@link MethodDescriptor.Marshaller} for a type. | ||
* | ||
* @param clazz the {@link Class} of the type to obtain the {@link MethodDescriptor.Marshaller} for | ||
* @param <T> the type to be marshalled | ||
* @return a {@link MethodDescriptor.Marshaller} for a type | ||
*/ | ||
<T> MethodDescriptor.Marshaller<T> get(Class<T> clazz); | ||
|
||
/** | ||
* Creates a default marshaller supplier. | ||
* | ||
* @return the default marshaller supplier | ||
*/ | ||
static MarshallerSupplier create() { | ||
return DefaultMarshallerSupplier.create(); | ||
} | ||
} |
Oops, something went wrong.