blob: a50395ee38f943e54e18945187a8a6e45482b1fc [file]
use crate::binary::mapper;
use crate::binary::sender::SenderKind;
use crate::streaming::session::Session;
use crate::streaming::systems::system::SharedSystem;
use anyhow::Result;
use iggy::error::IggyError;
use iggy::streams::get_stream::GetStream;
use tracing::debug;
pub async fn handle(
command: GetStream,
sender: &mut SenderKind,
session: &Session,
system: &SharedSystem,
) -> Result<(), IggyError> {
debug!("session: {session}, command: {command}");
let system = system.read().await;
let stream = system.find_stream(session, &command.stream_id);
if stream.is_err() {
sender.send_empty_ok_response().await?;
return Ok(());
}
let response = mapper::map_stream(stream?);
sender.send_ok_response(&response).await?;
Ok(())
}