[grpc-kotlin] Server-side deadlines / timeouts

104 views
Skip to first unread message

Thomas Cesare-Herriau

unread,
Sep 30, 2022, 4:42:02 PM9/30/22
to grpc.io
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 function on stubs), however there is no "Kotlin coroutine" equivalent to the io.grpc.Context#withDeadline 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: 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!
Reply all
Reply to author
Forward
0 new messages