Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3382474
D8883.id30129.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D8883.id30129.diff
View Options
diff --git a/services/backup/Cargo.lock b/services/backup/Cargo.lock
--- a/services/backup/Cargo.lock
+++ b/services/backup/Cargo.lock
@@ -627,6 +627,7 @@
"comm-services-lib",
"once_cell",
"rand",
+ "reqwest",
"tokio",
"tokio-stream",
"tonic-build",
@@ -820,6 +821,9 @@
"base64 0.21.2",
"chrono",
"derive_more",
+ "futures-core",
+ "futures-util",
+ "reqwest",
"serde",
"serde_json",
"tracing",
@@ -1038,6 +1042,21 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
[[package]]
name = "form_urlencoded"
version = "1.1.0"
@@ -1294,6 +1313,19 @@
"tokio-rustls",
]
+[[package]]
+name = "hyper-tls"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
+dependencies = [
+ "bytes",
+ "hyper",
+ "native-tls",
+ "tokio",
+ "tokio-native-tls",
+]
+
[[package]]
name = "iana-time-zone"
version = "0.1.53"
@@ -1357,6 +1389,12 @@
"windows-sys 0.42.0",
]
+[[package]]
+name = "ipnet"
+version = "2.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6"
+
[[package]]
name = "is-terminal"
version = "0.4.2"
@@ -1499,6 +1537,16 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
+[[package]]
+name = "mime_guess"
+version = "2.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
+dependencies = [
+ "mime",
+ "unicase",
+]
+
[[package]]
name = "miniz_oxide"
version = "0.7.1"
@@ -1526,6 +1574,24 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+[[package]]
+name = "native-tls"
+version = "0.2.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
+dependencies = [
+ "lazy_static",
+ "libc",
+ "log",
+ "openssl",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "security-framework",
+ "security-framework-sys",
+ "tempfile",
+]
+
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
@@ -1571,12 +1637,50 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
+[[package]]
+name = "openssl"
+version = "0.10.56"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e"
+dependencies = [
+ "bitflags 1.3.2",
+ "cfg-if",
+ "foreign-types",
+ "libc",
+ "once_cell",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.28",
+]
+
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+[[package]]
+name = "openssl-sys"
+version = "0.9.91"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
[[package]]
name = "os_str_bytes"
version = "6.4.1"
@@ -1856,6 +1960,46 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
+[[package]]
+name = "reqwest"
+version = "0.11.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55"
+dependencies = [
+ "base64 0.21.2",
+ "bytes",
+ "encoding_rs",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-tls",
+ "ipnet",
+ "js-sys",
+ "log",
+ "mime",
+ "mime_guess",
+ "native-tls",
+ "once_cell",
+ "percent-encoding",
+ "pin-project-lite",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "tokio",
+ "tokio-native-tls",
+ "tokio-util",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "wasm-streams",
+ "web-sys",
+ "winreg",
+]
+
[[package]]
name = "ring"
version = "0.16.20"
@@ -2270,6 +2414,16 @@
"syn 1.0.105",
]
+[[package]]
+name = "tokio-native-tls"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
+dependencies = [
+ "native-tls",
+ "tokio",
+]
+
[[package]]
name = "tokio-rustls"
version = "0.23.4"
@@ -2446,6 +2600,15 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
+[[package]]
+name = "unicase"
+version = "2.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
+dependencies = [
+ "version_check",
+]
+
[[package]]
name = "unicode-bidi"
version = "0.3.13"
@@ -2511,6 +2674,12 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
[[package]]
name = "version_check"
version = "0.9.4"
@@ -2570,6 +2739,18 @@
"wasm-bindgen-shared",
]
+[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "wasm-bindgen",
+ "web-sys",
+]
+
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.83"
@@ -2599,6 +2780,19 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
+[[package]]
+name = "wasm-streams"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078"
+dependencies = [
+ "futures-util",
+ "js-sys",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+]
+
[[package]]
name = "web-sys"
version = "0.3.60"
@@ -2827,6 +3021,15 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9"
+[[package]]
+name = "winreg"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "xmlparser"
version = "0.13.5"
diff --git a/services/backup/Cargo.toml b/services/backup/Cargo.toml
--- a/services/backup/Cargo.toml
+++ b/services/backup/Cargo.toml
@@ -14,7 +14,7 @@
aws-types = "0.55"
chrono = "0.4"
clap = { version = "4.0", features = ["derive", "env"] }
-comm-services-lib = { path = "../comm-services-lib", features = ["http"] }
+comm-services-lib = { path = "../comm-services-lib", features = ["http", "blob-client"] }
once_cell = "1.17"
rand = "0.8.5"
tokio = { version = "1.24", features = ["rt-multi-thread", "macros"] }
@@ -25,6 +25,7 @@
uuid = { version = "1.2", features = ["v4"] }
actix-web = "4.3"
tracing-actix-web = "0.7.3"
+reqwest = "0.11.18"
[build-dependencies]
tonic-build = "0.8"
diff --git a/services/backup/src/config.rs b/services/backup/src/config.rs
--- a/services/backup/src/config.rs
+++ b/services/backup/src/config.rs
@@ -15,8 +15,8 @@
#[arg(long)]
pub localstack_endpoint: Option<String>,
/// Blob service URL
- #[arg(long, default_value_t = DEFAULT_BLOB_SERVICE_URL.to_string())]
- pub blob_service_url: String,
+ #[arg(long, default_value = DEFAULT_BLOB_SERVICE_URL)]
+ pub blob_service_url: reqwest::Url,
}
/// Stores configuration parsed from command-line arguments
diff --git a/services/backup/src/constants.rs b/services/backup/src/constants.rs
--- a/services/backup/src/constants.rs
+++ b/services/backup/src/constants.rs
@@ -32,7 +32,7 @@
// Configuration defaults
pub const DEFAULT_HTTP_PORT: u16 = 51002;
-pub const DEFAULT_BLOB_SERVICE_URL: &str = "http://localhost:50053";
+pub const DEFAULT_BLOB_SERVICE_URL: &str = "http://localhost:51001";
// Environment variable names
pub const LOG_LEVEL_ENV_VAR: &str =
diff --git a/services/backup/src/http/mod.rs b/services/backup/src/http/mod.rs
--- a/services/backup/src/http/mod.rs
+++ b/services/backup/src/http/mod.rs
@@ -1,16 +1,21 @@
use actix_web::{web, App, HttpServer};
use anyhow::Result;
+use comm_services_lib::blob::client::BlobServiceClient;
use tracing::info;
use crate::{database::DatabaseClient, CONFIG};
-pub async fn run_http_server(db_client: DatabaseClient) -> Result<()> {
+pub async fn run_http_server(
+ db_client: DatabaseClient,
+ blob_client: BlobServiceClient,
+) -> Result<()> {
info!(
"Starting HTTP server listening at port {}",
CONFIG.http_port
);
let db = web::Data::new(db_client);
+ let blob = web::Data::new(blob_client);
HttpServer::new(move || {
App::new()
@@ -19,6 +24,7 @@
CONFIG.localstack_endpoint.is_some(),
))
.app_data(db.clone())
+ .app_data(blob.clone())
.service(
web::resource("/hello").route(web::get().to(|| async { "world" })),
)
diff --git a/services/backup/src/main.rs b/services/backup/src/main.rs
--- a/services/backup/src/main.rs
+++ b/services/backup/src/main.rs
@@ -1,4 +1,5 @@
use anyhow::Result;
+use comm_services_lib::blob::client::BlobServiceClient;
use tracing::Level;
use tracing_subscriber::EnvFilter;
@@ -29,8 +30,9 @@
let aws_config = config::load_aws_config().await;
let db_client = database::DatabaseClient::new(&aws_config);
+ let blob_client = BlobServiceClient::new(CONFIG.blob_service_url.clone());
- http::run_http_server(db_client).await?;
+ http::run_http_server(db_client, blob_client).await?;
Ok(())
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 10:59 AM (21 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2596736
Default Alt Text
D8883.id30129.diff (10 KB)
Attached To
Mode
D8883: [backup] Use blob client
Attached
Detach File
Event Timeline
Log In to Comment