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-Java 依赖版本到 1.61.0 #50

Merged
merged 1 commit into from
Mar 19, 2024
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
Expand Up @@ -17,8 +17,6 @@
package com.tencent.polaris.grpc.client;


import static com.tencent.polaris.grpc.loadbalance.PolarisLoadBalancerProvider.LOADBALANCER_PROVIDER;

import com.google.common.annotations.VisibleForTesting;
import com.tencent.polaris.api.pojo.ServiceKey;
import com.tencent.polaris.client.api.SDKContext;
Expand All @@ -34,7 +32,9 @@
import io.grpc.ManagedChannelBuilder;
import io.grpc.NameResolver.Factory;
import io.grpc.ProxyDetector;
import shade.polaris.com.google.gson.Gson;

import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
Expand All @@ -44,9 +44,8 @@
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;

import shade.polaris.com.google.gson.Gson;
import static com.tencent.polaris.grpc.loadbalance.PolarisLoadBalancerProvider.LOADBALANCER_PROVIDER;

/**
* @author <a href="mailto:[email protected]">liaochuntao</a>
Expand Down Expand Up @@ -79,7 +78,7 @@ public static PolarisManagedChannelBuilder forTarget(String target) {
/**
* 增强 {@link ManagedChannelBuilder#forTarget(String)}, 在连接到目标服务时允许设置主调服务的相关信息
*
* @param target 服务名
* @param target 服务名
* @param sourceService {@link ServiceKey} 主调服务信息以及标签
* @return {@link PolarisManagedChannelBuilder}
*/
Expand All @@ -90,9 +89,9 @@ public static PolarisManagedChannelBuilder forTarget(String target, ServiceKey s
/**
* 增强 {@link ManagedChannelBuilder#forTarget(String)}, 在连接到目标服务时允许设置主调服务的相关信息, 并且可以自定义北极星 SDK 的核心数据结构 {@link SDKContext}
*
* @param target 服务名
* @param target 服务名
* @param sourceService {@link ServiceKey} 主调服务信息以及标签
* @param sdkContext {@link SDKContext} 可以设置北极星 SDK 的相关配置以及行为, 例如服务治理中心地址等等
* @param sdkContext {@link SDKContext} 可以设置北极星 SDK 的相关配置以及行为, 例如服务治理中心地址等等
* @return {@link PolarisManagedChannelBuilder}
*/
public static PolarisManagedChannelBuilder forTarget(String target, ServiceKey sourceService, SDKContext sdkContext) {
Expand Down Expand Up @@ -220,8 +219,8 @@ public PolarisManagedChannelBuilder useTransportSecurity() {
return this;
}

@Deprecated
public PolarisManagedChannelBuilder enableFullStreamDecompression() {
this.builder.enableFullStreamDecompression();
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.tencent.polaris.api.utils.StringUtils;
import com.tencent.polaris.client.api.SDKContext;
import com.tencent.polaris.grpc.interceptor.PolarisServerInterceptor;
import io.grpc.BinaryLog;
import io.grpc.BindableService;
import io.grpc.CompressorRegistry;
import io.grpc.DecompressorRegistry;
Expand All @@ -28,15 +29,20 @@
import io.grpc.ServerBuilder;
import io.grpc.ServerInterceptor;
import io.grpc.ServerServiceDefinition;
import io.grpc.ServerStreamTracer;
import io.grpc.ServerTransportFilter;

import javax.annotation.Nullable;
import java.io.File;
import java.io.InputStream;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
import java.util.concurrent.TimeUnit;

/**
* @author <a href="mailto:[email protected]">liaochuntao</a>
Expand Down Expand Up @@ -90,7 +96,7 @@ public static PolarisGrpcServerBuilder forPort(int port) {
ServerBuilder<?> builder = ServerBuilder.forPort(port);
return new PolarisGrpcServerBuilder(builder);
}

/**
* PolarisGrpcServerBuilder Constructor.
*
Expand All @@ -110,7 +116,7 @@ public PolarisGrpcServerBuilder sdkContext(SDKContext context) {
this.context = context;
return this;
}

/**
* Set grpc service name.
*
Expand All @@ -121,7 +127,7 @@ public PolarisGrpcServerBuilder applicationName(String applicationName) {
this.applicationName = applicationName;
return this;
}

/**
* Namespace registered by grpc service.
*
Expand All @@ -132,7 +138,7 @@ public PolarisGrpcServerBuilder namespace(String namespace) {
this.namespace = namespace;
return this;
}

/**
* Set metadata.
*
Expand Down Expand Up @@ -170,7 +176,7 @@ public PolarisGrpcServerBuilder heartbeatInterval(int heartbeatInterval) {
this.heartbeatInterval = heartbeatInterval;
return this;
}

/**
* Set the local host.
*
Expand Down Expand Up @@ -250,6 +256,91 @@ public PolarisGrpcServerBuilder intercept(ServerInterceptor interceptor) {
return this;
}


@Override
public PolarisGrpcServerBuilder addTransportFilter(ServerTransportFilter filter) {
builder.addTransportFilter(filter);
return this;
}

@Override
public PolarisGrpcServerBuilder addStreamTracerFactory(ServerStreamTracer.Factory factory) {
builder.addStreamTracerFactory(factory);
return this;
}

@Override
public PolarisGrpcServerBuilder useTransportSecurity(InputStream certChain, InputStream privateKey) {
super.useTransportSecurity(certChain, privateKey);
return this;
}

@Override
public PolarisGrpcServerBuilder handshakeTimeout(long timeout, TimeUnit unit) {
builder.handshakeTimeout(timeout, unit);
return this;
}

@Override
public PolarisGrpcServerBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
builder.keepAliveTime(keepAliveTime, timeUnit);
return this;
}

@Override
public PolarisGrpcServerBuilder keepAliveTimeout(long keepAliveTimeout, TimeUnit timeUnit) {
builder.keepAliveTimeout(keepAliveTimeout, timeUnit);
return this;
}

@Override
public PolarisGrpcServerBuilder maxConnectionIdle(long maxConnectionIdle, TimeUnit timeUnit) {
builder.maxConnectionIdle(maxConnectionIdle, timeUnit);
return this;
}

@Override
public PolarisGrpcServerBuilder maxConnectionAge(long maxConnectionAge, TimeUnit timeUnit) {
builder.maxConnectionAge(maxConnectionAge, timeUnit);
return this;
}

@Override
public PolarisGrpcServerBuilder maxConnectionAgeGrace(long maxConnectionAgeGrace, TimeUnit timeUnit) {
builder.maxConnectionAgeGrace(maxConnectionAgeGrace, timeUnit);
return this;
}

@Override
public PolarisGrpcServerBuilder permitKeepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
builder.permitKeepAliveTime(keepAliveTime, timeUnit);
return this;
}

@Override
public PolarisGrpcServerBuilder permitKeepAliveWithoutCalls(boolean permit) {
builder.permitKeepAliveWithoutCalls(permit);
return this;
}

@Override
public PolarisGrpcServerBuilder maxInboundMessageSize(int bytes) {
builder.maxInboundMessageSize(bytes);
return this;
}

@Override
public PolarisGrpcServerBuilder maxInboundMetadataSize(int bytes) {
builder.maxInboundMetadataSize(bytes);
return this;
}

@Override
public PolarisGrpcServerBuilder setBinaryLog(BinaryLog binaryLog) {
builder.setBinaryLog(binaryLog);
return this;
}

/**
* 延迟注册, 用户可以通过设置 {@link DelayRegister} 来延迟 gRPC-server 注册到 polaris 对外提供服务的时间
* 默认支持策略
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<guava.version>31.1-jre</guava.version>
<slf4j-api.version>1.7.32</slf4j-api.version>
<junit-jupiter.version>RELEASE</junit-jupiter.version>
<grpc.version>1.42.1</grpc.version>
<grpc.version>1.61.0</grpc.version>
<polaris-dependencies.version>1.11.1</polaris-dependencies.version>
<maven.jar.plugin.version>3.0.0</maven.jar.plugin.version>
<maven.source.plugin.version>3.2.0</maven.source.plugin.version>
Expand Down
Loading