fix(client): Use Stream instead of TrySteam for client calls (#61)

This commit is contained in:
Juan Alvarez
2019-10-10 11:39:35 -04:00
committed by Lucio Franco
parent 8cddf8a12c
commit 7eda823c9c
5 changed files with 16 additions and 21 deletions
+4 -4
View File
@@ -65,7 +65,7 @@ impl<T> Grpc<T> {
M1: Send + 'static,
M2: Send + 'static,
{
let request = request.map(|m| stream::once(future::ok(m)));
let request = request.map(|m| stream::once(future::ready(m)));
self.client_streaming(request, path, codec).await
}
@@ -81,7 +81,7 @@ impl<T> Grpc<T> {
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>,
<T::ResponseBody as HttpBody>::Data: Into<Bytes>,
S: Stream<Item = Result<M1, Status>> + Send + 'static,
S: Stream<Item = M1> + Send + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + 'static,
M2: Send + 'static,
@@ -118,7 +118,7 @@ impl<T> Grpc<T> {
M1: Send + 'static,
M2: Send + 'static,
{
let request = request.map(|m| stream::once(future::ok(m)));
let request = request.map(|m| stream::once(future::ready(m)));
self.streaming(request, path, codec).await
}
@@ -134,7 +134,7 @@ impl<T> Grpc<T> {
T::ResponseBody: Body + HttpBody + Send + 'static,
<T::ResponseBody as HttpBody>::Data: Into<Bytes>,
<T::ResponseBody as HttpBody>::Error: Into<crate::Error>,
S: Stream<Item = Result<M1, Status>> + Send + 'static,
S: Stream<Item = M1> + Send + 'static,
C: Codec<Encode = M1, Decode = M2>,
M1: Send + 'static,
M2: Send + 'static,
+2 -2
View File
@@ -29,9 +29,9 @@ pub(crate) fn encode_client<T, U>(
) -> EncodeBody<impl Stream<Item = Result<BytesBuf, Status>>>
where
T: Encoder<Error = Status>,
U: Stream<Item = Result<T::Item, Status>>,
U: Stream<Item = T::Item>,
{
let stream = encode(encoder, source).into_stream();
let stream = encode(encoder, source.map(|x| Ok(x))).into_stream();
EncodeBody::new_client(stream)
}