diff --git a/services/backup/blob_client/src/get_client.rs b/services/backup/blob_client/src/get_client.rs --- a/services/backup/blob_client/src/get_client.rs +++ b/services/backup/blob_client/src/get_client.rs @@ -6,9 +6,7 @@ use proto::GetRequest; use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY}; -use crate::tools::{ - c_char_pointer_to_string, string_to_c_char_pointer, -}; +use crate::tools::{c_char_pointer_to_string, string_to_c_char_pointer}; use anyhow::bail; use crate::RUNTIME; use lazy_static::lazy_static; diff --git a/services/backup/blob_client/src/put_client.rs b/services/backup/blob_client/src/put_client.rs --- a/services/backup/blob_client/src/put_client.rs +++ b/services/backup/blob_client/src/put_client.rs @@ -8,9 +8,7 @@ use proto::PutRequest; use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY}; -use crate::tools::{ - c_char_pointer_to_string, string_to_c_char_pointer, -}; +use crate::tools::{c_char_pointer_to_string, string_to_c_char_pointer}; use anyhow::bail; use crate::RUNTIME; use lazy_static::lazy_static; @@ -122,30 +120,24 @@ Ok(response) => { let mut inner_response = response.into_inner(); loop { - match inner_response.message().await { - Ok(maybe_response_message) => { - let mut result = false; - if let Some(response_message) = maybe_response_message { - // warning: this will produce an error if there's more unread - // responses than MPSC_CHANNEL_BUFFER_CAPACITY - // you should then use put_client_blocking_read_cxx in order - // to dequeue the responses in c++ and make room for more - if let Ok(_) = response_thread_tx - .try_send((response_message.data_exists as i32).to_string()) - { - result = true; - } else { - bail!("response queue full"); - } - } - if !result { - break; - } + let maybe_response_message = inner_response.message().await?; + let mut result = false; + if let Some(response_message) = maybe_response_message { + // warning: this will produce an error if there's more unread + // responses than MPSC_CHANNEL_BUFFER_CAPACITY + // you should then use put_client_blocking_read_cxx in order + // to dequeue the responses in c++ and make room for more + if let Ok(_) = response_thread_tx + .try_send((response_message.data_exists as i32).to_string()) + { + result = true; + } else { + bail!("response queue full"); } - Err(err) => { - bail!(err.to_string()); - } - }; + } + if !result { + break; + } } } Err(err) => { @@ -189,7 +181,10 @@ bail!("couldn't receive data via client's receiver"); } } else { - bail!(format!("no client detected for {} in blocking read", holder)); + bail!(format!( + "no client detected for {} in blocking read", + holder + )); } } else { bail!("couldn't access clients"); @@ -245,9 +240,7 @@ let maybe_client = clients.remove(&holder); if let Some(client) = maybe_client { drop(client.tx); - RUNTIME.block_on(async { - client.rx_handle.await? - })?; + RUNTIME.block_on(async { client.rx_handle.await? })?; } else { bail!("no client detected in terminate"); }