Go - WaitForReady and timeout

133 views
Skip to first unread message

Amit Saha

unread,
Jul 24, 2021, 4:40:45 AM7/24/21
to grpc.io
For unary RPC method calls, passing a context to the RPC method call
is an Ok way to ensure that WaitForReady() doesn't hang forever.
This is however tricky for streaming RPC method call, since setting
the context also determines how long the entire stream will live for.

Is there a way to implement an upper limit on how long WaitForRead()
waits for the channel to reach the READY state? I think a dedicated
goroutine to monitor
the state of the channel may work such that it is invoked every time
we have a RPC method call..?

Thanks,
Amit.

Menghan Li

unread,
Jul 29, 2021, 2:14:39 PM7/29/21
to grpc.io
There's unfortunately no existing way to do this.

One option is to start a goroutine when creating the stream and do your own timeout.

Amit Saha

unread,
Jul 29, 2021, 6:46:52 PM7/29/21
to Menghan Li, grpc.io
On Fri, Jul 30, 2021 at 4:14 AM 'Menghan Li' via grpc.io
<grp...@googlegroups.com> wrote:
>
> There's unfortunately no existing way to do this.
>
> One option is to start a goroutine when creating the stream and do your own timeout.

Thanks, I was thinking the same.

>
> On Saturday, July 24, 2021 at 1:40:45 AM UTC-7 amits...@gmail.com wrote:
>>
>> For unary RPC method calls, passing a context to the RPC method call
>> is an Ok way to ensure that WaitForReady() doesn't hang forever.
>> This is however tricky for streaming RPC method call, since setting
>> the context also determines how long the entire stream will live for.
>>
>> Is there a way to implement an upper limit on how long WaitForRead()
>> waits for the channel to reach the READY state? I think a dedicated
>> goroutine to monitor
>> the state of the channel may work such that it is invoked every time
>> we have a RPC method call..?
>>
>> Thanks,
>> Amit.
>
> --
> 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+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/f2a58120-121a-42ec-bfdc-2539df2ca840n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages