Page MenuHomePhabricator

D5013.diff
No OneTemporary

D5013.diff

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
@@ -1 +1,73 @@
+mod proto {
+ tonic::include_proto!("blob");
+}
+use proto::blob_service_client::BlobServiceClient;
+use proto::GetRequest;
+
+use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY};
+use lazy_static::lazy_static;
+use libc;
+use libc::c_char;
+use std::ffi::CStr;
+use std::sync::{Arc, Mutex};
+use tokio::runtime::Runtime;
+use tokio::sync::mpsc;
+use tokio::task::JoinHandle;
+use tracing::error;
+
+struct ReadClient {
+ rx: mpsc::Receiver<Vec<u8>>,
+ rx_handle: JoinHandle<()>,
+}
+
+lazy_static! {
+ static ref CLIENT: Arc<Mutex<Option<ReadClient>>> =
+ Arc::new(Mutex::new(None));
+ static ref RUNTIME: Runtime = Runtime::new().unwrap();
+ static ref ERROR_MESSAGES: Arc<Mutex<Vec<String>>> =
+ Arc::new(Mutex::new(Vec::new()));
+}
+
+fn is_initialized() -> bool {
+ if let Ok(client) = CLIENT.lock() {
+ if client.is_some() {
+ return true;
+ }
+ } else {
+ report_error("couldn't access client".to_string());
+ }
+ false
+}
+
+fn report_error(message: String) {
+ println!("[RUST] [get] Error: {}", message);
+ if let Ok(mut error_messages) = ERROR_MESSAGES.lock() {
+ error_messages.push(message);
+ }
+ error!("could not access error messages");
+}
+
+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> {
+ unimplemented!();
+}
+
+pub fn get_client_blocking_read_cxx() -> Result<Vec<u8>, String> {
+ unimplemented!();
+}
+
+pub fn get_client_terminate_cxx() -> Result<(), String> {
+ unimplemented!();
+}
diff --git a/services/backup/blob_client/src/lib.rs b/services/backup/blob_client/src/lib.rs
--- a/services/backup/blob_client/src/lib.rs
+++ b/services/backup/blob_client/src/lib.rs
@@ -7,6 +7,10 @@
put_client_terminate_cxx, put_client_write_cxx,
};
+use get_client::{
+ get_client_blocking_read_cxx, get_client_initialize_cxx,
+ get_client_terminate_cxx,
+};
#[cxx::bridge]
mod ffi {
extern "Rust" {
@@ -17,5 +21,10 @@
) -> Result<()>;
fn put_client_blocking_read_cxx() -> Result<String>;
fn put_client_terminate_cxx() -> Result<()>;
+ unsafe fn get_client_initialize_cxx(
+ holder_char: *const c_char,
+ ) -> Result<()>;
+ fn get_client_blocking_read_cxx() -> Result<Vec<u8>>;
+ fn get_client_terminate_cxx() -> Result<()>;
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 9:31 PM (21 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581027
Default Alt Text
D5013.diff (2 KB)

Event Timeline