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 native image support in SE #2733

Merged
merged 2 commits into from
Feb 11, 2021
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
* Copyright (c) 2020, 2021 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 Expand Up @@ -45,14 +45,16 @@ final class FeatureCatalog {
.description("Server for gRPC services")
.path("grpc")
.flavor(HelidonFlavor.SE)
.nativeSupported(false));
.nativeSupported(true)
.nativeDescription("Experimental support in native image"));
add("io.helidon.grpc.client",
FeatureDescriptor.builder()
.name("gRPC Client")
.description("Client for gRPC services")
.path("grpcClient")
.flavor(HelidonFlavor.SE)
.nativeSupported(false));
.nativeSupported(true)
.nativeDescription("Experimental support in native image"));
addSe("io.helidon.grpc.metrics",
"Metrics",
"Metrics for gRPC services",
Expand Down Expand Up @@ -415,7 +417,8 @@ final class FeatureCatalog {
.name("EL")
.description("ABAC Jakarta Expression Language policy support")
.path("Security", "Provider", "ABAC", "Policy", "EL")
.nativeSupported(false));
.nativeSupported(true)
.nativeDescription("Properties used in expressions must have reflection configuration added"));
add("io.helidon.security.abac.role",
"Role",
"ABAC Role based attribute validator",
Expand Down Expand Up @@ -581,6 +584,8 @@ final class FeatureCatalog {
exclude("io.helidon.tracing.tracerresolver");
exclude("io.helidon.webclient.jaxrs");
exclude("io.helidon.webclient.spi");
exclude("io.helidon.common.context.spi");
exclude("io.helidon.grpc.core");
}

static Set<FeatureDescriptor> get(String packageName) {
Expand Down
8 changes: 4 additions & 4 deletions docs/se/aot/01_introduction.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2020 Oracle and/or its affiliates.
Copyright (c) 2020, 2021 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 Expand Up @@ -68,7 +68,7 @@ for native image.
|✅ |{nbsp} |Integration: gRPC |{nbsp}
|✅ |{nbsp} |OIDC |{nbsp}
|✅ |{nbsp} |Provider: ABAC |{nbsp}
| |{nbsp} |Provider/ABAC/Policy: EL |Not yet tested.
| |{nbsp} |Provider/ABAC/Policy: EL |Not yet tested.
|✅ |{nbsp} |Provider/ABAC: Role |{nbsp}
|✅ |{nbsp} |Provider/ABAC: Scope |{nbsp}
|✅ |{nbsp} |Provider/ABAC: Time |{nbsp}
Expand Down Expand Up @@ -103,9 +103,9 @@ for native image.
|✅ |{nbsp} |Multi-part |{nbsp}
|❓ |{nbsp} |Prometheus |Not yet tested.
|✅ |{nbsp} |Websocket |Server only.
| |gRPC Server |gRPC Server |Not yet tested.
| |gRPC Server |gRPC Server |Since GraalVM 21.0.0
|✅ |{nbsp} |Metrics |{nbsp}
| |gRPC Client |gRPC Client |Not yet tested.
| |gRPC Client |gRPC Client |Since GraalVM 21.0.0
|✅ |{nbsp} |Metrics |{nbsp}
|===

18 changes: 18 additions & 0 deletions examples/grpc/client-standalone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Helidon gRPC Standalone client

An example gRPC client. Can be used with the `basics` example that would act as a server.

This example is created to test native image on pure client side, so it does not have a server side
implemented.

## Build and run

```bash
mvn package
java -jar target/helidon-examples-grpc-client-standalone.jar
```

The client invokes the string service on the server, and should print out:
```
Text 'abcde' to upper is 'ABCDE'
```
87 changes: 87 additions & 0 deletions examples/grpc/client-standalone/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2021 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-se</artifactId>
<version>2.2.1-SNAPSHOT</version>
<relativePath>../../../applications/se/pom.xml</relativePath>
</parent>
<groupId>io.helidon.examples.grpc</groupId>
<artifactId>helidon-examples-grpc-client-standalone</artifactId>
<name>Helidon gRPC Server Examples Standalone client</name>

<description>
A standalone client invoking a strings gRPC service (such as in basics example)
</description>

<properties>
<mainClass>io.helidon.grpc.examples.client.standalone.StandaloneClient</mainClass>
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.grpc</groupId>
<artifactId>helidon-grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.grpc</groupId>
<artifactId>helidon-grpc-client</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2021 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.examples.client.standalone;

import io.helidon.grpc.examples.common.StringServiceGrpc;
import io.helidon.grpc.examples.common.Strings;

import io.grpc.Channel;
import io.grpc.ManagedChannelBuilder;

/**
* A gRPC client using only client side libraries.
* To test it, please setup a server, such as the one in "basics" example of Helidon grpc examples.
*/
public class StandaloneClient {
private StandaloneClient() {
}

/**
* Start the client with a single invocation to the server.
*
* @param args ignored
*/
public static void main(String[] args) {
Channel channel = ManagedChannelBuilder.forAddress("localhost", 1408)
.usePlaintext()
.build();

StringServiceGrpc.StringServiceBlockingStub stub = StringServiceGrpc.newBlockingStub(channel);

String text = "lower case original";
Strings.StringMessage request = Strings.StringMessage.newBuilder().setText(text).build();
Strings.StringMessage response = stub.upper(request);

System.out.println("Text '" + text + "' to upper case is '" + response.getText() + "'");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2021 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.
*/

/**
* Standalone gRPC client example.
*/
package io.helidon.grpc.examples.client.standalone;
31 changes: 31 additions & 0 deletions examples/grpc/client-standalone/src/main/proto/strings.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2021 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.
*/


syntax = "proto3";
option java_package = "io.helidon.grpc.examples.common";

service StringService {
rpc Upper (StringMessage) returns (StringMessage) {}
rpc Lower (StringMessage) returns (StringMessage) {}
rpc Split (StringMessage) returns (stream StringMessage) {}
rpc Join (stream StringMessage) returns (StringMessage) {}
rpc Echo (stream StringMessage) returns (stream StringMessage) {}
}

message StringMessage {
string text = 1;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2021 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 All @@ -14,6 +14,7 @@
# limitations under the License.
#

io.helidon.security.abac.scope.ScopeValidator
io.helidon.security.abac.policy.PolicyValidator
io.helidon.security.abac.time.TimeValidator
handlers=io.helidon.common.HelidonConsoleHandler
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n

.level=INFO
3 changes: 2 additions & 1 deletion examples/grpc/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2021 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 Expand Up @@ -40,5 +40,6 @@
<module>security-abac</module>
<module>security-outbound</module>
<module>microprofile</module>
<module>client-standalone</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name": "java.time.ZonedDateTime",
"methods": [
{
"name": "getYear",
"parameterTypes": []
}
]
}
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"annotated": [],
"class-hierarchy": [
"com.google.protobuf.MessageLiteOrBuilder"
],
"classes": [
],
"exclude": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2021 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.
#

Args=--initialize-at-build-time=com.google \
--initialize-at-build-time=io.grpc \
--initialize-at-run-time=io.netty.handler.ssl.ReferenceCountedOpenSslContext \
--initialize-at-run-time=io.grpc.netty.NettyServerBuilder \
--initialize-at-run-time=io.grpc.Context$LazyStorage \
--initialize-at-run-time=io.grpc.netty.Utils$ByteBufAllocatorPreferDirectHolder \
--initialize-at-run-time=io.grpc.netty.Utils$ByteBufAllocatorPreferHeapHolder \
--initialize-at-run-time=io.helidon.grpc.core.JsonbMarshaller \
--allow-incomplete-classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"annotated": [],
"class-hierarchy": [
"javax.el.ExpressionFactory"
],
"classes": [
],
"exclude": []
}
Loading