Skip to content

Commit 36e1a7f

Browse files
authored
Log if GRPC server/channel exceeds shutdown timeout (#33)
1 parent b5dd950 commit 36e1a7f

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ Current status: 6/79 tests pass
151151

152152
Known issues:
153153

154-
* `fs2-grpc` server implementation doesn't support setting response headers (which is required by the tests)
155-
* `google.protobuf.Any` serialization doesn't follow Connect-RPC spec
154+
* `fs2-grpc` server implementation doesn't support setting response headers (which is required by the tests): [#31](https://github.com/igor-vovk/connect-rpc-scala/issues/31)
155+
* `google.protobuf.Any` serialization doesn't follow Connect-RPC spec: [#32](https://github.com/igor-vovk/connect-rpc-scala/issues/32)
156156

157157
## Future improvements
158158

core/src/main/scala/org/ivovk/connect_rpc_scala/InProcessChannelBridge.scala

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package org.ivovk.connect_rpc_scala
22

33
import cats.Endo
44
import cats.effect.{Resource, Sync}
5-
import cats.implicits.*
65
import io.grpc.*
76
import io.grpc.inprocess.{InProcessChannelBuilder, InProcessServerBuilder}
7+
import org.slf4j.{Logger, LoggerFactory}
88

99
import java.util.concurrent.TimeUnit
1010
import scala.concurrent.duration.Duration
@@ -13,6 +13,8 @@ import scala.util.chaining.*
1313

1414
object InProcessChannelBridge {
1515

16+
private val logger: Logger = LoggerFactory.getLogger(getClass)
17+
1618
def create[F[_] : Sync](
1719
services: Seq[ServerServiceDefinition],
1820
serverBuilderConfigurator: Endo[ServerBuilder[?]] = identity,
@@ -40,8 +42,13 @@ object InProcessChannelBridge {
4042
.build()
4143
.start()
4244
}
43-
val release = (s: Server) =>
44-
Sync[F].delay(s.shutdown().awaitTermination(waitForShutdown.toMillis, TimeUnit.MILLISECONDS)).void
45+
val release = (s: Server) => Sync[F].delay {
46+
val res = s.shutdown().awaitTermination(waitForShutdown.toMillis, TimeUnit.MILLISECONDS)
47+
48+
if (!res) {
49+
logger.warn(s"GRPC server did not shut down in $waitForShutdown")
50+
}
51+
}
4552

4653
Resource.make(acquire)(release)
4754
}
@@ -57,8 +64,13 @@ object InProcessChannelBridge {
5764
.pipe(channelBuilderConfigurator)
5865
.build()
5966
}
60-
val release = (c: ManagedChannel) =>
61-
Sync[F].delay(c.shutdown().awaitTermination(waitForShutdown.toMillis, TimeUnit.MILLISECONDS)).void
67+
val release = (c: ManagedChannel) => Sync[F].delay {
68+
val res = c.shutdown().awaitTermination(waitForShutdown.toMillis, TimeUnit.MILLISECONDS)
69+
70+
if (!res) {
71+
logger.warn(s"GRPC channel did not shut down in $waitForShutdown")
72+
}
73+
}
6274

6375
Resource.make(acquire)(release)
6476
}

0 commit comments

Comments
 (0)