Skip to content

Commit

Permalink
Add serviceConfig in buildMutualTlsChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
renjiezh committed Sep 29, 2022
1 parent b7fdf21 commit 9b3087d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package org.wfanet.measurement.common.grpc

import io.grpc.ManagedChannel
import io.grpc.netty.NettyChannelBuilder
import io.netty.channel.ChannelOption
import java.security.cert.X509Certificate
import java.time.Duration
import org.wfanet.measurement.common.crypto.SigningCerts
Expand All @@ -32,12 +33,18 @@ import org.wfanet.measurement.common.crypto.SigningCerts
fun buildMutualTlsChannel(
target: String,
clientCerts: SigningCerts,
hostName: String? = null
hostName: String? = null,
serviceConfig: Map<String, *>? = null,
): ManagedChannel {
val channelBuilder =
NettyChannelBuilder.forTarget(target)
.directExecutor() // See https://github.com/grpc/grpc-kotlin/issues/263
.sslContext(clientCerts.toClientTlsContext())

if(serviceConfig != null) {
channelBuilder.defaultServiceConfig(serviceConfig).enableRetry()
}

return if (hostName == null) {
channelBuilder.build()
} else {
Expand Down

0 comments on commit 9b3087d

Please sign in to comment.