we are now running search server at the same port as the whole backend service

This commit is contained in:
filipriec
2025-06-08 21:53:48 +02:00
parent 7c4ac1eebc
commit 645172747a

View File

@@ -21,24 +21,14 @@ use common::proto::multieko2::{
table_script::table_script_server::TableScriptServer, table_script::table_script_server::TableScriptServer,
auth::auth_service_server::AuthServiceServer auth::auth_service_server::AuthServiceServer
}; };
use search::run_search_service; use search::{SearcherService, SearcherServer};
pub async fn run_server(db_pool: sqlx::PgPool) -> Result<(), Box<dyn std::error::Error>> { pub async fn run_server(db_pool: sqlx::PgPool) -> Result<(), Box<dyn std::error::Error>> {
// Initialize JWT for authentication // Initialize JWT for authentication
crate::auth::logic::jwt::init_jwt()?; crate::auth::logic::jwt::init_jwt()?;
// ==================== SEARCH SERVER SETUP ==================
let search_addr = "[::1]:50052".to_string();
println!("Spawning Search Service on {}", search_addr);
tokio::spawn(async move {
if let Err(e) = run_search_service(&search_addr).await {
eprintln!("[Error] Search service failed to start: {}", e);
}
});
// ============================================================
let addr = "[::1]:50051".parse()?; let addr = "[::1]:50051".parse()?;
println!("Unified Server listening on {}", addr);
let reflection_service = ReflectionBuilder::configure() let reflection_service = ReflectionBuilder::configure()
.register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET) .register_encoded_file_descriptor_set(FILE_DESCRIPTOR_SET)
@@ -49,6 +39,7 @@ pub async fn run_server(db_pool: sqlx::PgPool) -> Result<(), Box<dyn std::error:
let tables_data_service = TablesDataService { db_pool: db_pool.clone() }; let tables_data_service = TablesDataService { db_pool: db_pool.clone() };
let table_script_service = TableScriptService { db_pool: db_pool.clone() }; let table_script_service = TableScriptService { db_pool: db_pool.clone() };
let auth_service = AuthServiceImpl { db_pool: db_pool.clone() }; let auth_service = AuthServiceImpl { db_pool: db_pool.clone() };
let search_service = SearcherService;
Server::builder() Server::builder()
.add_service(AdresarServer::new(AdresarService { db_pool: db_pool.clone() })) .add_service(AdresarServer::new(AdresarService { db_pool: db_pool.clone() }))
@@ -58,6 +49,7 @@ pub async fn run_server(db_pool: sqlx::PgPool) -> Result<(), Box<dyn std::error:
.add_service(TablesDataServer::new(tables_data_service)) .add_service(TablesDataServer::new(tables_data_service))
.add_service(TableScriptServer::new(table_script_service)) .add_service(TableScriptServer::new(table_script_service))
.add_service(AuthServiceServer::new(auth_service)) .add_service(AuthServiceServer::new(auth_service))
.add_service(SearcherServer::new(search_service))
.add_service(reflection_service) .add_service(reflection_service)
.serve(addr) .serve(addr)
.await?; .await?;