diff --git a/rust/rhgitaly/src/streaming.rs b/rust/rhgitaly/src/streaming.rs index 1e5ee2a7be9f146d4636db2524bc87cf4d595759_cnVzdC9yaGdpdGFseS9zcmMvc3RyZWFtaW5nLnJz..ce0a1e85d6f777cd5180cfba624255c0141c2380_cnVzdC9yaGdpdGFseS9zcmMvc3RyZWFtaW5nLnJz 100644 --- a/rust/rhgitaly/src/streaming.rs +++ b/rust/rhgitaly/src/streaming.rs @@ -7,7 +7,7 @@ use std::str::FromStr; use lazy_static::lazy_static; -use tokio::sync::mpsc::Sender; +use tokio::sync::mpsc::{self, Sender}; use tokio_stream::wrappers::ReceiverStream; use tonic::{Response, Status}; use tracing::error; @@ -26,6 +26,12 @@ pub type ResultResponseStream<Resp> = 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 /// /// Server streaming methods involving a repository typically spawn a new thread with