Skip to content

Commit

Permalink
Update gRPC version to 1.60.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Dec 13, 2023
1 parent 15ae7ef commit 9271ca9
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 64 deletions.
8 changes: 6 additions & 2 deletions config/etcd/pom.xml
Expand Up @@ -57,8 +57,12 @@
</dependency>
<!-- etcd v3 -->
<dependency>
<groupId>io.helidon.grpc</groupId>
<artifactId>io.grpc</artifactId>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
Expand Down
6 changes: 3 additions & 3 deletions config/etcd/src/main/java/module-info.java
Expand Up @@ -24,9 +24,9 @@
requires java.logging;
requires transitive io.helidon.config;
requires etcd4j;
requires grpc.protobuf;
requires grpc.stub;
requires grpc.api;
requires io.grpc.protobuf;
requires io.grpc.stub;
requires io.grpc;
requires com.google.protobuf;
requires com.google.common;
requires io.helidon.common;
Expand Down
2 changes: 1 addition & 1 deletion dependencies/pom.xml
Expand Up @@ -63,7 +63,7 @@
<version.lib.graphql-java>18.6</version.lib.graphql-java>
<version.lib.graphql-java.extended.scalars>18.3</version.lib.graphql-java.extended.scalars>
<version.lib.gson>2.9.0</version.lib.gson>
<version.lib.grpc>1.57.1</version.lib.grpc>
<version.lib.grpc>1.60.0</version.lib.grpc>
<version.lib.guava>32.0.1-jre</version.lib.guava>
<version.lib.h2>1.4.200</version.lib.h2>
<version.lib.hamcrest>1.3</version.lib.hamcrest>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 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 @@ -100,9 +100,14 @@ public Optional<String> loadBalancerPolicy() {

/**
* Get the {@link NameResolver.Factory} to use.
* <p>
* This method is deprecated due to the deprecation of the
* {@link io.grpc.ManagedChannelBuilder#nameResolverFactory(io.grpc.NameResolver.Factory)}
* method in the gRPC Java API.
*
* @return the optional {@link NameResolver.Factory} to use
*/
@Deprecated
public Optional<NameResolver.Factory> nameResolverFactory() {
return Optional.ofNullable(nameResolver);
}
Expand Down Expand Up @@ -216,11 +221,16 @@ public Builder loadBalancerPolicy(String policy) {
/**
* Set the {@link io.grpc.NameResolver.Factory} to use.
* @param factory the {@link io.grpc.NameResolver.Factory} to use
* <p>
* This method is deprecated due to the deprecation of the
* {@link io.grpc.ManagedChannelBuilder#nameResolverFactory(io.grpc.NameResolver.Factory)}
* method in the gRPC Java API.
*
* @return this instance for fluent API
*
* @see io.grpc.ManagedChannelBuilder#nameResolverFactory(io.grpc.NameResolver.Factory)
*/
@Deprecated
public Builder nameResolverFactory(NameResolver.Factory factory) {
this.nameResolver = factory;
return this;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 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 @@ -155,6 +155,7 @@ Map<String, GrpcChannelDescriptor> channels() {
return channelConfigs;
}

@SuppressWarnings("deprecation")
private ManagedChannel createChannel(GrpcChannelDescriptor descriptor) {
ManagedChannelBuilder<?> builder = descriptor.tlsDescriptor()
.map(tlsDescriptor -> createNettyChannelBuilder(descriptor, tlsDescriptor))
Expand Down
5 changes: 4 additions & 1 deletion grpc/client/src/main/java/module-info.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 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 @@ -20,6 +20,9 @@
module io.helidon.grpc.client {
exports io.helidon.grpc.client;

requires io.grpc.netty;
requires io.netty.handler;

requires transitive io.helidon.grpc.core;

requires io.helidon.tracing;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 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 @@ -34,7 +34,10 @@

import io.grpc.EquivalentAddressGroup;
import io.grpc.NameResolver;
import io.grpc.NameResolverProvider;
import io.grpc.NameResolverRegistry;
import io.grpc.StatusRuntimeException;

import io.netty.handler.codec.DecoderException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -208,12 +211,11 @@ public void shouldConnectWithCaCertAndClientCertAndClientKeyTo2WaySslServer() th

@Test
public void shouldUseTarget() throws Exception {
FakeNameResolverFactory factory = new FakeNameResolverFactory(portNoSsl);
NameResolverRegistry.getDefaultRegistry().register(new FakeNameResolverProvider("foo", portNoSsl));
String channelKey = "ChannelKey";
GrpcChannelDescriptor.Builder builder = GrpcChannelDescriptor
.builder()
.target("foo://bar.com")
.nameResolverFactory(factory);
.target("foo://bar.com");

GrpcChannelsProvider provider = GrpcChannelsProvider.builder()
.channel(channelKey, builder.build())
Expand Down Expand Up @@ -303,6 +305,39 @@ public NameResolver.Args getArgs() {
}
}

private static class FakeNameResolverProvider extends NameResolverProvider {
private final String scheme;
private final int port;
private URI targetUri;
private NameResolver.Args args;

public FakeNameResolverProvider(String scheme, int port) {
this.scheme = scheme;
this.port = port;
}

@Override
protected boolean isAvailable() {
return true;
}

@Override
protected int priority() {
return 0;
}

@Override
public NameResolver newNameResolver(URI targetUri, NameResolver.Args args) {
this.targetUri = targetUri;
this.args = args;
return new FakeNameResolver(port);
}

@Override
public String getDefaultScheme() {
return scheme;
}
}

private static class FakeNameResolver extends NameResolver {
private final int port;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 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 @@ -36,6 +36,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;

@SuppressWarnings("deprecation")
public class GrpcChannelsProviderTest {

private static final String CLIENT_CERT = "ssl/clientCert.pem";
Expand Down
50 changes: 13 additions & 37 deletions grpc/core/pom.xml
Expand Up @@ -40,33 +40,27 @@
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common-configurable</artifactId>
</dependency>

<dependency>
<groupId>io.helidon.grpc</groupId>
<artifactId>io.grpc</artifactId>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-inprocess</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
Expand All @@ -76,32 +70,14 @@
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down
10 changes: 5 additions & 5 deletions grpc/core/src/main/java/module-info.java
Expand Up @@ -31,11 +31,11 @@
requires io.helidon.common.context;
requires io.helidon.common.http;

requires grpc.netty;
requires transitive grpc.protobuf;
requires transitive grpc.api;
requires grpc.protobuf.lite;
requires transitive grpc.stub;
requires io.grpc.netty;
requires transitive io.grpc.protobuf;
requires io.grpc.protobuf.lite;
requires transitive io.grpc.stub;
requires transitive io.grpc;
requires io.netty.handler;
requires io.netty.transport;
requires transitive com.google.protobuf;
Expand Down
5 changes: 5 additions & 0 deletions grpc/io.grpc/pom.xml
Expand Up @@ -32,6 +32,11 @@
<name>Helidon grpc-java Bundle</name>
<description>Bundle of grpc dependencies provided for backwards compatibility</description>

<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<spotbugs.skip>true</spotbugs.skip>
</properties>

<dependencies>
<dependency>
<groupId>io.grpc</groupId>
Expand Down
21 changes: 21 additions & 0 deletions grpc/io.grpc/src/main/java/module-info.java
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 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.
*/

/**
* The deprecated repackaged gRPC Module.
*/
module io.helidon.grpc.deprecated {
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023 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 @@ -16,6 +16,8 @@

package io.helidon.grpc.server;

import java.time.Duration;

import io.helidon.common.context.Context;
import io.helidon.grpc.core.GrpcTlsDescriptor;

Expand Down Expand Up @@ -43,6 +45,10 @@ public class GrpcServerBasicConfig

private final Context context;

private final int maxRapidResets;

private final Duration rapidResetCheckPeriod;

/**
* Construct {@link GrpcServerBasicConfig} instance.
*
Expand All @@ -58,6 +64,8 @@ private GrpcServerBasicConfig(GrpcServerConfiguration.Builder builder) {
this.tracingConfig = builder.tracingConfig();
this.workers = builder.workers();
this.tlsConfig = builder.tlsConfig();
this.maxRapidResets = builder.maxRapidResets();
this.rapidResetCheckPeriod = builder.rapidResetCheckPeriod();
}

/**
Expand Down Expand Up @@ -133,4 +141,14 @@ public int workers() {
public GrpcTlsDescriptor tlsConfig() {
return tlsConfig;
}

@Override
public Duration rapidResetCheckPeriod() {
return rapidResetCheckPeriod;
}

@Override
public int maxRapidResets() {
return maxRapidResets;
}
}

0 comments on commit 9271ca9

Please sign in to comment.