Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3342565
D5095.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D5095.diff
View Options
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
@@ -9,8 +9,7 @@
use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY};
use crate::tools::{
- c_char_pointer_to_string, c_char_pointer_to_string_new, check_error,
- report_error, string_to_c_char_pointer, string_to_c_char_pointer_new,
+ c_char_pointer_to_string, c_char_pointer_to_string_new, report_error, string_to_c_char_pointer_new,
};
use anyhow::bail;
use crate::RUNTIME;
@@ -195,36 +194,24 @@
pub fn put_client_blocking_read_cxx(
holder_char: *const c_char,
-) -> Result<String, String> {
- let holder = c_char_pointer_to_string(holder_char)?;
- check_error(&ERROR_MESSAGES)?;
- let response: Option<String> = RUNTIME.block_on(async {
+) -> anyhow::Result<String, anyhow::Error> {
+ let holder = c_char_pointer_to_string_new(holder_char)?;
+ Ok(RUNTIME.block_on(async {
if let Ok(mut clients) = CLIENTS.lock() {
let maybe_client = clients.get_mut(&holder);
if let Some(client) = maybe_client {
if let Some(data) = client.rx.recv().await {
- return Some(data);
+ return Ok(data);
} else {
- report_error(
- &ERROR_MESSAGES,
- "couldn't receive data via client's receiver",
- Some("put"),
- );
+ bail!("couldn't receive data via client's receiver");
}
} else {
- report_error(
- &ERROR_MESSAGES,
- "no client detected in blocking read",
- Some("put"),
- );
+ bail!(format!("no client detected for {} in blocking read", holder));
}
} else {
- report_error(&ERROR_MESSAGES, "couldn't access client", Some("put"));
+ bail!("couldn't access clients");
}
- None
- });
- check_error(&ERROR_MESSAGES)?;
- response.ok_or("response not received properly".to_string())
+ })?)
}
/**
diff --git a/services/backup/blob_client/src/tools.rs b/services/backup/blob_client/src/tools.rs
--- a/services/backup/blob_client/src/tools.rs
+++ b/services/backup/blob_client/src/tools.rs
@@ -19,18 +19,6 @@
error!("could not access error messages");
}
-pub fn check_error(
- error_messages: &Mutex<Vec<String>>,
-) -> Result<(), String> {
- if let Ok(errors) = error_messages.lock() {
- return match errors.is_empty() {
- true => Ok(()),
- false => Err(errors.join("\n")),
- };
- }
- Err("could not access error messages".to_string())
-}
-
pub fn c_char_pointer_to_string(
c_char_pointer: *const c_char,
) -> Result<String, String> {
@@ -48,16 +36,6 @@
Ok(holder_cstr.to_str()?.to_owned())
}
-pub fn string_to_c_char_pointer(
- signs: &String,
-) -> Result<*const c_char, String> {
- let cstr = CString::new((&signs).as_bytes());
- match cstr {
- Ok(result) => Ok(result.as_ptr()),
- Err(err) => Err(err.to_string()),
- }
-}
-
pub fn string_to_c_char_pointer_new(
signs: &String,
) -> anyhow::Result<*const c_char, anyhow::Error> {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 1:38 AM (18 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2567159
Default Alt Text
D5095.diff (3 KB)
Attached To
Mode
D5095: [services] Backup - Blob Get Client - Refactor put read
Attached
Detach File
Event Timeline
Log In to Comment