Skip to content
Snippets Groups Projects
Commit ce0a1e85 authored by Georges Racinet's avatar Georges Racinet
Browse files

rhgitaly::streaming: utility for empty response streams

Probably more complicated than it should, but it works and can
be swapped later to something more straightforward.
parent 1e5ee2a7
No related branches found
No related tags found
2 merge requests!189Merged stable branch into default and bumped VERSION,!188RHGitaly CommitService.GetTreeEntries implementation
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
use std::str::FromStr; use std::str::FromStr;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use tokio::sync::mpsc::Sender; use tokio::sync::mpsc::{self, Sender};
use tokio_stream::wrappers::ReceiverStream; use tokio_stream::wrappers::ReceiverStream;
use tonic::{Response, Status}; use tonic::{Response, Status};
use tracing::error; use tracing::error;
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
pub type ResultResponseStream<Resp> = pub type ResultResponseStream<Resp> =
Result<Response<ReceiverStream<Result<Resp, Status>>>, Status>; Result<Response<ReceiverStream<Result<Resp, Status>>>, Status>;
/// Return a valid, yet empty response stream
pub fn empty_response_stream<Resp>() -> ResultResponseStream<Resp> {
let (_tx, rx) = mpsc::channel(1);
Ok(Response::new(ReceiverStream::new(rx)))
}
/// A specialization of [`Sender`] allowing only blocking sends and logging sending errors /// A specialization of [`Sender`] allowing only blocking sends and logging sending errors
/// ///
/// Server streaming methods involving a repository typically spawn a new thread with /// Server streaming methods involving a repository typically spawn a new thread with
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment