From 2471335b306a069fc7c4f8d5ca3b984ecefccdeb Mon Sep 17 00:00:00 2001 From: Marcin Olichwiruk <21108638+olichwiruk@users.noreply.github.com> Date: Wed, 4 Oct 2023 01:09:29 +0200 Subject: [PATCH] refactor: replace Arc with web::Data for oca_facade_web_data variable --- Cargo.lock | 4 +++- src/startup.rs | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1fec87..6f56bb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1669,7 +1669,9 @@ dependencies = [ [[package]] name = "oca-rs" -version = "0.3.0-rc.18" +version = "0.3.0-rc.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac16a1ab54391b15d8aeb29261f105ceaf3a870a899d062bbbbb0d06ca6e569" dependencies = [ "convert_case 0.6.0", "dyn-clonable", diff --git a/src/startup.rs b/src/startup.rs index 539dd50..c931e81 100644 --- a/src/startup.rs +++ b/src/startup.rs @@ -2,7 +2,6 @@ use crate::routes::health_check; use oca_rs::{data_storage::DataStorage, repositories::SQLiteConfig}; // use crate::routes::namespaces; use crate::routes::{explore, internal, objects, oca_bundles}; -use std::sync::Arc; use actix_web::dev::Server; use actix_web::{web, App, HttpServer}; @@ -34,11 +33,12 @@ pub fn run( ) -> Result { let server = HttpServer::new(move || { // let auth = HttpAuthentication::bearer(validator); - let facade_arc = Arc::new(std::sync::Mutex::new(oca_rs::Facade::new( - data_storage.clone(), - filesystem_storage.clone(), - cache_storage_config.clone(), - ))); + let oca_facade_web_data = + web::Data::new(std::sync::Mutex::new(oca_rs::Facade::new( + data_storage.clone(), + filesystem_storage.clone(), + cache_storage_config.clone(), + ))); let oca_bundles_scope = web::scope("/oca-bundles") .route("", web::post().to(oca_bundles::add_oca_file)) .route("/search", web::get().to(oca_bundles::search)) @@ -54,7 +54,7 @@ pub fn run( web::get().to(oca_bundles::get_oca_data_entry), ); App::new() - .app_data(web::Data::from(facade_arc)) + .app_data(oca_facade_web_data.clone()) .route("/health_check", web::get().to(health_check)) /* .route("/namespaces", web::post().to(namespaces::add_namespace)) .service(