Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3398105
D7444.id25329.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7444.id25329.diff
View Options
diff --git a/services/blob/src/http/mod.rs b/services/blob/src/http/mod.rs
new file mode 100644
--- /dev/null
+++ b/services/blob/src/http/mod.rs
@@ -0,0 +1,33 @@
+use crate::config::CONFIG;
+use crate::database::DatabaseClient;
+use crate::s3::S3Client;
+
+use actix_web::{web, App, HttpServer};
+use anyhow::Result;
+use tracing::info;
+
+async fn hello_handler() -> impl actix_web::Responder {
+ "Hello, world!"
+}
+
+// disable unused warning for now
+#[allow(unused)]
+pub async fn run_http_server(
+ db_client: DatabaseClient,
+ s3_client: S3Client,
+) -> Result<()> {
+ info!(
+ "Starting HTTP server listening at port {}",
+ CONFIG.http_port
+ );
+ HttpServer::new(move || {
+ App::new()
+ .wrap(tracing_actix_web::TracingLogger::default())
+ .service(web::resource("/hello").route(web::get().to(hello_handler)))
+ })
+ .bind(("0.0.0.0", CONFIG.http_port))?
+ .run()
+ .await?;
+
+ Ok(())
+}
diff --git a/services/blob/src/main.rs b/services/blob/src/main.rs
--- a/services/blob/src/main.rs
+++ b/services/blob/src/main.rs
@@ -2,6 +2,7 @@
pub mod constants;
pub mod database;
pub mod grpc;
+pub mod http;
pub mod s3;
pub mod tools;
@@ -28,5 +29,8 @@
let db = database::DatabaseClient::new(&aws_config);
let s3 = s3::S3Client::new(&aws_config);
- crate::grpc::run_grpc_server(db, s3).await
+ tokio::select! {
+ http_result = crate::http::run_http_server(db.clone(), s3.clone()) => http_result,
+ grpc_result = crate::grpc::run_grpc_server(db, s3) => grpc_result,
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 8:57 PM (20 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608554
Default Alt Text
D7444.id25329.diff (1 KB)
Attached To
Mode
D7444: [services][blob] Introduce HTTP server
Attached
Detach File
Event Timeline
Log In to Comment