Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2834911
D5031.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D5031.diff
View Options
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,7 +6,7 @@
use proto::GetRequest;
use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY};
-use crate::tools::report_error;
+use crate::tools::{check_error, report_error};
use lazy_static::lazy_static;
use libc;
use libc::c_char;
@@ -40,16 +40,6 @@
false
}
-fn check_error() -> 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 get_client_initialize_cxx(
holder_char: *const c_char,
) -> Result<(), String> {
@@ -122,7 +112,7 @@
}
pub fn get_client_blocking_read_cxx() -> Result<Vec<u8>, String> {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
let response: Option<Vec<u8>> = RUNTIME.block_on(async {
if let Ok(mut maybe_client) = CLIENT.lock() {
if let Some(mut client) = (*maybe_client).take() {
@@ -138,14 +128,14 @@
}
None
});
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
response.ok_or("response could not be obtained".to_string())
}
pub fn get_client_terminate_cxx() -> Result<(), String> {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
if !is_initialized() {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
return Ok(());
}
if let Ok(mut maybe_client) = CLIENT.lock() {
@@ -170,6 +160,6 @@
!is_initialized(),
"client transmitter handler released properly"
);
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
Ok(())
}
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,7 +8,7 @@
use proto::PutRequest;
use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY};
-use crate::tools::report_error;
+use crate::tools::{report_error, check_error};
use lazy_static::lazy_static;
use libc;
use libc::c_char;
@@ -50,16 +50,6 @@
}
}
-fn check_error() -> 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 put_client_initialize_cxx() -> Result<(), String> {
if is_initialized() {
put_client_terminate_cxx()?;
@@ -180,7 +170,7 @@
}
pub fn put_client_blocking_read_cxx() -> Result<String, String> {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
let response: Option<String> = RUNTIME.block_on(async {
if let Ok(mut maybe_client) = CLIENT.lock() {
if let Some(mut client) = (*maybe_client).take() {
@@ -202,7 +192,7 @@
}
None
});
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
response.ok_or("response not received properly".to_string())
}
@@ -216,7 +206,7 @@
field_index: usize,
data: *const c_char,
) -> Result<(), String> {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
let data_c_str: &CStr = unsafe { CStr::from_ptr(data) };
let data_bytes: Vec<u8> = data_c_str.to_bytes().to_vec();
@@ -246,14 +236,14 @@
report_error(&ERROR_MESSAGES, "couldn't access client", Some("put"));
}
});
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
Ok(())
}
pub fn put_client_terminate_cxx() -> Result<(), String> {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
if !is_initialized() {
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
return Ok(());
}
@@ -280,6 +270,6 @@
!is_initialized(),
"client transmitter handler released properly"
);
- check_error()?;
+ check_error(&ERROR_MESSAGES)?;
Ok(())
}
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
@@ -16,3 +16,13 @@
}
error!("could not access error messages");
}
+
+pub fn check_error(error_messages: &Arc<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())
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 29, 12:10 PM (19 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2200548
Default Alt Text
D5031.diff (4 KB)
Attached To
Mode
D5031: [services] Rust Integration - Backup - Make check_error shared
Attached
Detach File
Event Timeline
Log In to Comment