// TODO: this test needs to interleave requests with responses and check along the way.
// Need to find a way to model that with the blocking API.
this test needs to interleave requests with responses and check along the way.
Need to find a way to model that with the blocking API.
this test needs to interleave requests with responses and check along the way . Need to find a way to model that with the blocking API .
fn ping_pong(client: TestServiceClient) {
    let mut requests = Vec::new();
    for &size_body_len in [(31415, 27182), (9, 8), (2653, 1828), (58979, 45904)].iter() {
        let mut req = StreamingOutputCallRequest::new();
        let mut params = ResponseParameters::new();
        params.set_size(size_body_len.0);
        req.set_response_parameters(::protobuf::RepeatedField::from_vec(vec![params]));
        let mut payload = Payload::new();
        payload.set_body(vec![0;size_body_len.1]);
        req.set_payload(payload);
        requests.push(req);
    }
    let response = client.full_duplex_call(grpc::RequestOptions::new(), grpc::StreamingRequest::iter(requests)).wait_drop_metadata();
    let mut response_sizes = Vec::new();
    {
        // this scope is to satisfy the borrow checker.
        let bar = response.map(|result| {
            response_sizes.push(result.unwrap().get_payload().body.len());
        });
        assert!(bar.count() == 4);
    }
    println!("response_sizes.len is {}", response_sizes.len());
    assert!(response_sizes.len() == 4);
    assert!(response_sizes[0] == 31415);
    assert!(response_sizes[1] == 9);
    assert!(response_sizes[2] == 2653);
    assert!(response_sizes[3] == 58979);
    println!("{} PingPong done", Local::now().to_rfc3339());
}
fn ping_pong ( client : TestServiceClient ) { let mut requests = Vec :: new ( ) ; for & size_body_len in [ ( 31415 , 27182 ) , ( 9 , 8 ) , ( 2653 , 1828 ) , ( 58979 , 45904 ) ] . iter ( ) { let mut req = StreamingOutputCallRequest :: new ( ) ; let mut params = ResponseParameters :: new ( ) ; params . set_size ( size_body_len . 0 ) ; req . set_response_parameters ( :: protobuf :: RepeatedField :: from_vec ( vec ! [ params ] ) ) ; let mut payload = Payload :: new ( ) ; payload . set_body ( vec ! [ 0 size_body_len 1 ] ) ; req . set_payload ( payload ) ; requests . push ( req ) ; } let response = client . full_duplex_call ( grpc :: RequestOptions :: new ( ) , grpc :: StreamingRequest :: iter ( requests ) ) . wait_drop_metadata ( ) ; let mut response_sizes = Vec :: new ( ) ; { // this scope is to satisfy the borrow checker. let bar = response . map ( | result | { response_sizes . push ( result . unwrap ( ) . get_payload ( ) . body . len ( ) ) ; } ) ; assert ! ( bar count ( ) 4 ) ; } println ! ( " " response_sizes len ( ) ) ; assert ! ( response_sizes len ( ) 4 ) ; assert ! ( response_sizes [ 0 ] 31415 ) ; assert ! ( response_sizes [ 1 ] 9 ) ; assert ! ( response_sizes [ 2 ] 2653 ) ; assert ! ( response_sizes [ 3 ] 58979 ) ; println ! ( " " Local now ( ) to_rfc3339 ( ) ) ; }
TODO: this test needs to interleave requests with responses and check along the way.
TODO : this test needs to interleave requests with responses and check along the way .
client
TestServiceClient