Skip to content

Commit 3d703d2

Browse files
authored
Add possibility for interceptors in the GrpcPods client (#131)
* Add possibility for interceptors in the GrpcPods client * Add docs to new config variable
1 parent 96ce5a3 commit 3d703d2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.devsisters.shardcake
22

33
import zio._
4+
import scalapb.zio_grpc.ZClientInterceptor
45

56
import java.util.concurrent.Executor
67

@@ -10,10 +11,16 @@ import java.util.concurrent.Executor
1011
* @param maxInboundMessageSize the maximum message size allowed to be received by the grpc client
1112
* @param executor a custom executor to pass to grpc-java when creating gRPC clients and servers
1213
* @param shutdownTimeout the timeout to wait for the gRPC server to shutdown before forcefully shutting it down
14+
* @param interceptors the interceptors to be used by the gRPC client, e.g for adding tracing or logging
1315
*/
14-
case class GrpcConfig(maxInboundMessageSize: Int, executor: Option[Executor], shutdownTimeout: Duration)
16+
case class GrpcConfig(
17+
maxInboundMessageSize: Int,
18+
executor: Option[Executor],
19+
shutdownTimeout: Duration,
20+
interceptors: Seq[ZClientInterceptor]
21+
)
1522

1623
object GrpcConfig {
1724
val default: GrpcConfig =
18-
GrpcConfig(maxInboundMessageSize = 32 * 1024 * 1024, None, 3.seconds)
25+
GrpcConfig(maxInboundMessageSize = 32 * 1024 * 1024, None, 3.seconds, Seq.empty)
1926
}

protocol-grpc/src/main/scala/com/devsisters/shardcake/GrpcPods.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GrpcPods(
4141
}
4242
}
4343

44-
val channel = ZManagedChannel(builder)
44+
val channel = ZManagedChannel(builder, config.interceptors)
4545
// create a fiber that never ends and keeps the connection alive
4646
for {
4747
_ <- ZIO.logDebug(s"Opening connection to pod $pod")

0 commit comments

Comments
 (0)