From 51cb6aadce3857fcaa077554ec1426b48b489649 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Wed, 21 Jun 2023 13:24:00 +0200 Subject: [PATCH] use Box for origin::Store --- src/domain/manager.rs | 20 +++++++++++--------- src/origin/store/git.rs | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/domain/manager.rs b/src/domain/manager.rs index 024805c..7e2f9b1 100644 --- a/src/domain/manager.rs +++ b/src/domain/manager.rs @@ -146,7 +146,7 @@ pub trait Manager: Sync + Send { } struct ManagerImpl { - origin_store: sync::Arc, + origin_store: Box, domain_config_store: sync::Arc, domain_checker: checker::DNSChecker, acme_manager: Option>, @@ -179,22 +179,24 @@ async fn sync_origins(origin_store: &dyn origin::store::Store, canceller: Cancel pub fn new( task_stack: &mut util::TaskStack, - origin_store: sync::Arc, + origin_store: Box, domain_config_store: sync::Arc, domain_checker: checker::DNSChecker, acme_manager: Option>, ) -> sync::Arc { - task_stack.spawn(|canceller| { - let origin_store = origin_store.clone(); - async move { Ok(sync_origins(origin_store.as_ref(), canceller).await) } - }); - - sync::Arc::new(ManagerImpl { + let manager = sync::Arc::new(ManagerImpl { origin_store, domain_config_store, domain_checker, acme_manager, - }) + }); + + task_stack.spawn(|canceller| { + let manager = manager.clone(); + async move { Ok(sync_origins(manager.origin_store.as_ref(), canceller).await) } + }); + + manager } impl Manager for ManagerImpl { diff --git a/src/origin/store/git.rs b/src/origin/store/git.rs index 1f1768a..f10fed0 100644 --- a/src/origin/store/git.rs +++ b/src/origin/store/git.rs @@ -71,9 +71,9 @@ struct Store { origins: sync::RwLock>>, } -pub fn new(dir_path: PathBuf) -> io::Result> { +pub fn new(dir_path: PathBuf) -> io::Result> { fs::create_dir_all(&dir_path)?; - Ok(sync::Arc::new(Store { + Ok(Box::new(Store { dir_path, sync_guard: sync::Mutex::new(collections::HashMap::new()), origins: sync::RwLock::new(collections::HashMap::new()),