It looks at the moment like the way to interact with a server-to-client stream is either with a BlockingStub or with just a Stub which I see is used for async operations.
How can the client cancel a stream from the server part way through when using the async stub?
I am thinking of using a server-to-client stream to return search results. Instead of having to bother with pagination, I want to return a stream, and let the client display as many items as the user wants to see as they scroll through the list, and terminate the stream when they click on an item.
Obviously, in this case the BlockingStub is no use because I don't want to load a potentially large dataset into memory first.
So, how can I cancel a server-to-client stream from the client? Can I get hold of the `call` object, and then invoke `call.cancel()` when I want, or can I just call `streamObserver.onCompleted()` whenever I want instead?
Call call = channel.newCall(config.listEvents)
blockingServerStreamingCall(
call, request);
}
If I rephrased my question as "Should I use an async stub or a blocking stub for search results?", you're saying I should use a blocking stub and just return the iterator, which will cause the underlying channel to request the next result from the stream as it's consumed? That would be what I'm looking for.
I think you're also suggesting that I call the following directly in my client code instead of using the generated method, so I have access to the 'call' object:
If the user wanted to run a different query I could invoke `call.cancel()` before making a new call.
On Sat, Mar 21, 2015 at 4:26 PM, <bean...@googlemail.com> wrote:I am thinking of using a server-to-client stream to return search results. Instead of having to bother with pagination, I want to return a stream, and let the client display as many items as the user wants to see as they scroll through the list, and terminate the stream when they click on an item.Oh, that makes sense. And flow control nicely pushes back on the server when the user hasn't needed to see more.
E0417 00:58:06.489979859 9215 channel.cc:78] assertion failed: GRPC_CALL_OK == grpc_call_start_batch(call->call(), ops, nops, buf) *** Aborted at 1429257486 (unix time) try "date -d @1429257486" if you are using GNU date ***
PC: @ 0x7f9a849e0cc9 (unknown)
*** SIGABRT (@0x3e8000023ff) received by PID 9215 (TID 0x7f9a85cf07c0) from PID 9215; stack trace: ***
@ 0x7f9a858d4340 (unknown)
@ 0x7f9a849e0cc9 (unknown)
@ 0x7f9a849e40d8 (unknown)
@ 0x4c843f grpc::Channel::PerformOpsOnCall()
@ 0x4119ab grpc::ClientReader<>::Finish()
--
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 post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oO9JwwEV6nUYM5N-zdeZuzpdBqTrd1SNEe4K9snWMWf6w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAD2hskwxFvv9HMy5qYU5gjkLzP%3DWpeVQhWgkTmAH-tXGJSPeQw%40mail.gmail.com.