Hi all!

*tl;dr: I'm looking for the right Kotlin idiomatic way to setup server-side 
deadlines.*

The grpc-kotlin wrapper to grpc-java already supports setting Deadlines on 
Client Stubs (using the withDeadline 
<https://grpc.github.io/grpc-java/javadoc/io/grpc/stub/AbstractStub.html#withDeadline-io.grpc.Deadline->
 
function on stubs), however there is no "Kotlin coroutine" equivalent to 
the io.grpc.Context#withDeadline 
<https://grpc.github.io/grpc-java/javadoc/io/grpc/Context.html#withDeadline-io.grpc.Deadline-java.util.concurrent.ScheduledExecutorService->
 
function that allows wrapping any operation into a Cancellable context with 
a deadline.

The problem is that the io.grpc.Context#withDeadline API requires using 
a ScheduledExecutorService, which as I understand it, would require 
bypassing Kotlin coroutine architecture. An alternative is to use 
withTimeout 
<https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-timeout.html>:
 
however this results in 2 separate contextual timeouts (the withTimeout one 
and a potential propagated gRPC Deadline in the context).

Am I missing something? What would be the recommended approach?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/3fd92026-280e-4a89-b028-10e165615df4n%40googlegroups.com.

Reply via email to