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 @@ -7,12 +7,12 @@ use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY}; use crate::tools::{check_error, report_error}; +use crate::RUNTIME; use lazy_static::lazy_static; use libc; use libc::c_char; use std::ffi::CStr; use std::sync::Mutex; -use tokio::runtime::Runtime; use tokio::sync::mpsc; use tokio::task::JoinHandle; @@ -24,7 +24,6 @@ lazy_static! { static ref CLIENT: Mutex> = Mutex::new(None); - static ref RUNTIME: Runtime = Runtime::new().unwrap(); static ref ERROR_MESSAGES: Mutex> = Mutex::new(Vec::new()); } 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 @@ -3,6 +3,9 @@ mod put_client; mod tools; +use lazy_static::lazy_static; +use tokio::runtime; + use put_client::{ put_client_blocking_read_cxx, put_client_initialize_cxx, put_client_terminate_cxx, put_client_write_cxx, @@ -12,6 +15,12 @@ get_client_blocking_read_cxx, get_client_initialize_cxx, get_client_terminate_cxx, }; + +lazy_static! { + static ref RUNTIME: runtime::Runtime = runtime::Runtime::new() + .expect("Unable to create tokio runtime"); +} + #[cxx::bridge] mod ffi { extern "Rust" { 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,12 +9,12 @@ use crate::constants::{BLOB_ADDRESS, MPSC_CHANNEL_BUFFER_CAPACITY}; use crate::tools::{report_error, check_error}; +use crate::RUNTIME; use lazy_static::lazy_static; use libc; use libc::c_char; use std::ffi::CStr; use std::sync::Mutex; -use tokio::runtime::Runtime; use tokio::sync::mpsc; use tokio::task::JoinHandle; @@ -35,7 +35,6 @@ static ref CLIENT: Mutex> = Mutex::new(None); // todo we should probably create separate clients for different IDs - static ref RUNTIME: Runtime = Runtime::new().unwrap(); static ref ERROR_MESSAGES: Mutex> = Mutex::new(Vec::new()); }