use Box for origin::Store

This commit is contained in:
Brian Picciano 2023-06-21 13:24:00 +02:00
parent 7dd52839b1
commit 51cb6aadce
2 changed files with 13 additions and 11 deletions

View File

@ -146,7 +146,7 @@ pub trait Manager: Sync + Send {
}
struct ManagerImpl {
origin_store: sync::Arc<dyn origin::store::Store>,
origin_store: Box<dyn origin::store::Store>,
domain_config_store: sync::Arc<dyn config::Store>,
domain_checker: checker::DNSChecker,
acme_manager: Option<sync::Arc<dyn acme::manager::Manager>>,
@ -179,22 +179,24 @@ async fn sync_origins(origin_store: &dyn origin::store::Store, canceller: Cancel
pub fn new(
task_stack: &mut util::TaskStack<unexpected::Error>,
origin_store: sync::Arc<dyn origin::store::Store>,
origin_store: Box<dyn origin::store::Store>,
domain_config_store: sync::Arc<dyn config::Store>,
domain_checker: checker::DNSChecker,
acme_manager: Option<sync::Arc<dyn acme::manager::Manager>>,
) -> sync::Arc<dyn Manager> {
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 {

View File

@ -71,9 +71,9 @@ struct Store {
origins: sync::RwLock<collections::HashMap<origin::Descr, sync::Arc<Origin>>>,
}
pub fn new(dir_path: PathBuf) -> io::Result<sync::Arc<dyn super::Store>> {
pub fn new(dir_path: PathBuf) -> io::Result<Box<dyn super::Store>> {
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()),