Skip to content

Commit

Permalink
disable retries by default in YDB GRPC channel
Browse files Browse the repository at this point in the history
disable retry in YDB GRPC channel by default due to grpc/grpc-java#9340
  • Loading branch information
egorlitvinenk committed Sep 22, 2022
1 parent 221ce44 commit fa4f31d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public class ChannelSettings {
private final Consumer<NettyChannelBuilder> channelInitializer;
private boolean useTLS;
private byte[] cert;
private boolean enableRetry = false;

private ChannelSettings(GrpcTransport.Builder builder) {
this.database = builder.getDatabase();
this.version = builder.getVersionString();
this.channelInitializer = builder.getChannelInitializer();
this.useTLS = builder.getUseTls();
this.cert = builder.getCert();
this.enableRetry = builder.isEnableRetry();
}

public String getDatabase() {
Expand All @@ -50,6 +52,10 @@ public boolean isUseTLS() {
return useTLS;
}

public boolean isEnableRetry() {
return enableRetry;
}

private SslContext createSslContext() {
try {
SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public GrpcChannel(EndpointRecord endpoint, ChannelSettings channelSettings) {
.withOption(ChannelOption.ALLOCATOR, ByteBufAllocator.DEFAULT);

channelSettings.getChannelInitializer().accept(channelBuilder);

if (channelSettings.isEnableRetry()) {
channelBuilder.enableRetry();
} else {
channelBuilder.disableRetry();
}

realChannel = channelBuilder.build();
channel = interceptChannel(realChannel, channelSettings);
}
Expand Down

0 comments on commit fa4f31d

Please sign in to comment.