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!