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

gRPC Client Implementation #8423

Merged
merged 38 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e275dd2
Initial commit based on in-progress work from Tomas.
spericas Jan 26, 2024
0d9378e
Additional work arounds tests and descriptors.
spericas Jan 26, 2024
9e89838
Simple unary method call without using stubs.
spericas Feb 7, 2024
d20a820
Basic support for unary, serverStream, streamClient and bidi invocati…
spericas Feb 9, 2024
907f81a
Support for sync and async gRPC calls.
spericas Feb 12, 2024
b3db2e0
Fixed problem with EOS and improved logging. All basic tests are pass…
spericas Feb 16, 2024
569bd6f
Initial support for gRPC stubs, async only for now.
spericas Feb 16, 2024
53fdc86
New test for gRPC that uses stubs. Fixes a number of checkstyle and c…
spericas Feb 20, 2024
0f33486
Use WebClient to create GrpcClient(s).
spericas Feb 21, 2024
bc2419d
Fixed unary blocking test.
spericas Feb 21, 2024
cf16c22
Support for TLS. Switched tests to use TLS.
spericas Feb 22, 2024
993b5c4
Simplified and optimized implementation of gRPC unary calls.
spericas Feb 23, 2024
1391a36
Moved test to webclient module.
spericas Feb 26, 2024
2365caf
Removed currently unused types from grpc core module.
spericas Feb 26, 2024
46aa20c
Cleanup of webserver gRPC module.
spericas Feb 26, 2024
5314a16
Test cleanup and copyright errors.
spericas Feb 26, 2024
5c09911
Adds support for setting up gRPC routes in tests. Updates gRPC tests …
spericas Feb 27, 2024
41c7d2c
Removes currently unused types.
spericas Feb 27, 2024
1cbf971
- Simplifies the grpc.core module to the bare minimum that is needed now
spericas Mar 13, 2024
0817032
Switches to socket context logging. Throws more detailed exception if…
spericas Mar 14, 2024
ad662cd
Converts PriorityBag to WeightedBag.
spericas Mar 14, 2024
4665870
Introduces support for client interceptors in low-level, stub-free API.
spericas Mar 18, 2024
92435ed
Basic support for client interceptors with service stubs
spericas Mar 19, 2024
5e98f7b
Improves support for empty server streams. Includes fix in Http2Clien…
spericas Apr 22, 2024
e6ff4a8
Adds more tests for client and server empty streams.
spericas Apr 23, 2024
984b4ed
Handles server EOS in HEADERS frame on the client side. Increased rea…
spericas Apr 23, 2024
7becac2
Some new tests from JK and fixes to gRPC client code to handle: (1) e…
spericas Apr 24, 2024
ee05b3a
Fixes problems in unary calls with large payloads.
spericas Apr 25, 2024
309f8a4
Use protobuf version for protoc.
spericas May 2, 2024
a11da57
Basic support for gRPC protocol config settings
spericas May 3, 2024
308161d
Javadoc updates.
spericas May 6, 2024
e17d6ee
Improves handling for server connection drops. On a read timeout, if …
spericas May 20, 2024
7fd5f7f
Uses a separate virtual thread to check if the connection to the serv…
spericas May 20, 2024
5bf8f9e
Sets heartbeat period to 0, thus disabling the feature by default.
spericas May 21, 2024
765fed9
Fixes logging message and test.
spericas May 21, 2024
1146ef5
Refactors a few classes in grpc/core. Addresses other comments in PR …
spericas May 28, 2024
b6f57d2
Reduces the number of logging statements in favor of using low-level …
spericas May 29, 2024
a1995d9
Some code reformatting using the Helidon scheme.
spericas May 30, 2024
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
4 changes: 4 additions & 0 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,10 @@
<groupId>io.helidon.webclient</groupId>
<artifactId>helidon-webclient-websocket</artifactId>
</dependency>
<dependency>
spericas marked this conversation as resolved.
Show resolved Hide resolved
<groupId>io.helidon.webclient</groupId>
<artifactId>helidon-webclient-grpc</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.webclient</groupId>
<artifactId>helidon-webclient-sse</artifactId>
Expand Down
16 changes: 16 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
<artifactId>helidon-microprofile-graphql-server</artifactId>
<version>${helidon.version}</version>
</dependency>
<!-- GRPC -->
<dependency>
<groupId>io.helidon.grpc</groupId>
<artifactId>helidon-grpc-core</artifactId>
<version>${helidon.version}</version>
</dependency>
<!-- Micronaut integrations -->
<dependency>
<groupId>io.helidon.integrations.micronaut</groupId>
Expand Down Expand Up @@ -1257,6 +1263,11 @@
<artifactId>helidon-webserver-testing-junit5-websocket</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.webserver.testing.junit5</groupId>
<artifactId>helidon-webserver-testing-junit5-grpc</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.webclient</groupId>
<artifactId>helidon-webclient-api</artifactId>
Expand All @@ -1282,6 +1293,11 @@
<artifactId>helidon-webclient-websocket</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.webclient</groupId>
<artifactId>helidon-webclient-grpc</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.webclient</groupId>
<artifactId>helidon-webclient-sse</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2022, 2023 Oracle and/or its affiliates.
# Copyright (c) 2022, 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.
Expand Down
69 changes: 69 additions & 0 deletions grpc/core/pom.xml
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>
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);
}
}
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() {
}
}
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();
}
}
Loading