From 66e8fc9b629c22417fc7573a499a5abdec713cb2 Mon Sep 17 00:00:00 2001 From: 0SkillAllLuck <43417046+0SkillAllLuck@users.noreply.github.com> Date: Thu, 18 Mar 2021 18:59:54 +0100 Subject: [PATCH] gRPC LoadBalancingPolicy Support --- .../grpc/runtime/config/GrpcClientConfiguration.java | 6 ++++++ .../java/io/quarkus/grpc/runtime/supports/Channels.java | 1 + 2 files changed, 7 insertions(+) diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcClientConfiguration.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcClientConfiguration.java index 8801f5036e283..0d1f94c7f5eea 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcClientConfiguration.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/config/GrpcClientConfiguration.java @@ -137,4 +137,10 @@ public class GrpcClientConfiguration { @ConfigItem public Optional userAgent; + /** + * Use a custom load balancing policy. + * Accepted values are: {@code pick_value}, {@code round_robin}, {@code grpclb} + */ + @ConfigItem(defaultValue = "pick_first") + public String loadBalancingPolicy; } diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java index a9c86fd383ee9..9fe04ee248977 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java @@ -86,6 +86,7 @@ public static Channel createChannel(String name) throws SSLException { } NettyChannelBuilder builder = NettyChannelBuilder.forAddress(host, port) + .defaultLoadBalancingPolicy(config.loadBalancingPolicy) .flowControlWindow(config.flowControlWindow.orElse(DEFAULT_FLOW_CONTROL_WINDOW)) .keepAliveWithoutCalls(config.keepAliveWithoutCalls) .maxHedgedAttempts(config.maxHedgedAttempts)