Consulting about zio-grpc bi-stream closing invoke: When it will be closed? I'm use grpcurl to test bistream, but zio-grpc server side not close immidently(it will closed after some time).
I'm watching grpc server-side stream close event by Stream.ensuring
. For detail:
request
.mapM { reqItem =>
// do action here
UIO(println(s"test get some data from request item: ${reqItem}"))
}
.runDrain
.catchAll(error => ZIO(println(s"find some error: $error")))
.ensuring {
UIO(println(s"request stream closed"))
}
.forkDaemon
ZStream.fromEffect {
Queue.unbounded[String].flatMap { queue =>
ZStream.fromQueue(queue)
}
}.flatten
.ensuring {UIO(println("response stream closed"))}
The code works well to handle request and response , besides, it will invoke some other business logic in ensuring
but ignored here for simplify.
Questions:
ZStream.ensuring
with zio-grpc?For furthermore test, grpcurl closed by Ctrl-C
will invoking server-side response stream closed firstly and immediately.
As for server-side request stream, not invoked, even though 5 minutes later.
I'm guess request stream lifecycle handle by client because it's beyond underlying HTTP2/TCP connection in gRPC level view.
It's should be some best practise in normal case: