Skip to content

Commit

Permalink
Raise size of max inbound msg size - main 2.x (#19358) (#19364)
Browse files Browse the repository at this point in the history
* Raise the default size of inbound message size in java bindings (#19325)

* max inbound buffers in scala client and deafult ledger client
  • Loading branch information
mziolekda authored Jun 11, 2024
1 parent 2d32b3e commit ef6425d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static final class Builder {
private Optional<String> accessToken = Optional.empty();
private Optional<Duration> timeout = Optional.empty();

public static final int DefaultMaxInboundMessageSize = 10 * 1024 * 1024;

private Builder(@NonNull NettyChannelBuilder channelBuilder) {
this.builder = channelBuilder;
this.builder.usePlaintext();
Expand Down Expand Up @@ -79,6 +81,11 @@ public Builder withTimeout(@NonNull Duration timeout) {
return this;
}

public Builder withMaxInboundMessageSize(int maxInboundMessageSize) {
this.builder.maxInboundMessageSize(maxInboundMessageSize);
return this;
}

public DamlLedgerClient build() {
return new DamlLedgerClient(
this.builder, this.expectedLedgerId, this.accessToken, this.timeout);
Expand All @@ -97,7 +104,9 @@ public DamlLedgerClient build() {
* builder's capabilities
*/
public static Builder newBuilder(@NonNull String host, int port) {
return new Builder(NettyChannelBuilder.forAddress(host, port));
return new Builder(
NettyChannelBuilder.forAddress(host, port)
.maxInboundMessageSize(Builder.DefaultMaxInboundMessageSize));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ import com.daml.ledger.client.LedgerClient
import com.daml.ledger.client.binding.DomainTransactionMapper.DecoderType
import com.daml.ledger.client.binding.retrying.CommandRetryFlow
import com.daml.ledger.client.binding.util.Slf4JLogger
import com.daml.ledger.client.configuration.LedgerClientConfiguration
import com.daml.ledger.client.configuration.{
LedgerClientChannelConfiguration,
LedgerClientConfiguration,
}
import com.daml.ledger.client.services.commands.CommandSubmission
import com.daml.ledger.client.services.commands.tracker.CompletionResponse.{
CompletionFailure,
CompletionSuccess,
}
import com.daml.util.Ctx
import io.grpc.ManagedChannel
import io.grpc.netty.NegotiationType.TLS
import io.grpc.netty.NettyChannelBuilder
import io.netty.handler.ssl.SslContext
import org.slf4j.LoggerFactory
import scalaz.syntax.tag._
Expand Down Expand Up @@ -146,14 +147,9 @@ class LedgerClientBinding(
object LedgerClientBinding {

def createChannel(host: String, port: Int, sslContext: Option[SslContext]): ManagedChannel = {
val builder = NettyChannelBuilder.forAddress(host, port)

sslContext match {
case Some(context) => builder.sslContext(context).negotiationType(TLS)
case None => builder.usePlaintext()
}

builder.build()
LedgerClientChannelConfiguration(sslContext)
.builderFor(host, port)
.build()
}

@nowarn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.netty.handler.ssl.SslContext
final case class LedgerClientChannelConfiguration(
sslContext: Option[SslContext],
maxInboundMetadataSize: Int = GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE,
maxInboundMessageSize: Int = GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE,
maxInboundMessageSize: Int = LedgerClientChannelConfiguration.DefaultMaxInboundMessageSize,
) {

def builderFor(host: String, port: Int): NettyChannelBuilder = {
Expand All @@ -29,6 +29,7 @@ final case class LedgerClientChannelConfiguration(

object LedgerClientChannelConfiguration {

val DefaultMaxInboundMessageSize: Int = 10 * 1024 * 1024
val InsecureDefaults: LedgerClientChannelConfiguration =
LedgerClientChannelConfiguration(sslContext = None)

Expand Down

0 comments on commit ef6425d

Please sign in to comment.