grpc-rs icon indicating copy to clipboard operation
grpc-rs copied to clipboard

request for ClientStream usage example, more examples and simpler examples

Open omac777 opened this issue 6 years ago • 2 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] I am having difficulty implementing a client stream. Please refer to this patch to a simple example outside of grpc-rs that reuses the grpc-rs crate to implement it. The original author had one Eat function and I added a SendFile function that attempts to use a grpc ClientStream. I have failed to use the passed in stream or even print out elements from the stream on the server side. I would appreciate some help why that is. https://github.com/mtp401/protoc-grpcio/issues/19#issuecomment-496679815

 service Diner {
   rpc Eat(Order) returns (Check) {}
+  rpc SendFile(stream SFFileChunk) returns (Check) {}
 }

Describe the solution you'd like A clear and concise description of what you want to happen. I would like to have a working simple example that uses a ClientStream. By the way, I'm not keen on using rust function chaining since it hides too many implementation details going on such as what explicit types are used everywhere. I want to see those types in order to read all the associated documentation and code about them.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. I have found c++/golang alternatives that do work, but I want to implement a rust language equivalent.

Additional context Add any other context or screenshots about the feature request here. Nothing to add here. I have said enough. Thank you for your consideration.

omac777 avatar May 28 '19 20:05 omac777

Have you tried looking at the examples?

Some of them are using client streams, are those what you're looking for?

https://github.com/pingcap/grpc-rs/blob/fec97d193a2c25c43dc61db6e1d8716e17ee9dcf/tests/cases/cancel.rs#L153-L160

ice1000 avatar Jun 01 '19 18:06 ice1000

Yes, I have looked at the examples, but that snippet you mentioned is not straightforward to follow. In fact I did try to reapply what you mentioned here: https://github.com/mtp401/protoc-grpcio/issues/19#issuecomment-496679815

        //stream.map(move |oneSFFileChunk| {
            //let mut theSFFileChunk : SFFileChunk;
            //theSFFileChunk = oneSFFileChunk.clone();                    
            //hexdump::hexdump(
            //         theSFFileChunk.get_sfonechunk()
            //);            
        //});

        //let f = stream.for_each( |_| Ok(()) );
        //Box::new(f);

        let f = stream.for_each(move |oneSFFileChunk| {
            let mut theSFFileChunk : SFFileChunk;
            theSFFileChunk = oneSFFileChunk.clone();                    
            hexdump::hexdump(
                theSFFileChunk.get_sfonechunk()
            );
            Ok(())
        });
        Box::new(f);

But on the server side it says "Failed to reply: RemoteStopped" and on the client side is says "c17 error while receiver wait: RpcFailure(RpcStatus { status: Cancelled, details: Some("Cancelled") }) c19"

omac777 avatar Jun 02 '19 06:06 omac777