diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-09 23:45:07 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-09 23:45:07 +0200 |
commit | d66c0d6833ddbeb61e34ee222dde92a5363bda1f (patch) | |
tree | 0e2da23fb32a6bf62a205fdf5f90d986ac14ad0c /src/server.rs | |
parent | a3eb88e6013e70238e7ddd66b4644f138b3d1b93 (diff) | |
download | garage-d66c0d6833ddbeb61e34ee222dde92a5363bda1f.tar.gz garage-d66c0d6833ddbeb61e34ee222dde92a5363bda1f.zip |
Why is it not Sync??
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/server.rs b/src/server.rs index cc7e5dce..d9f98164 100644 --- a/src/server.rs +++ b/src/server.rs @@ -5,7 +5,7 @@ use std::net::SocketAddr; use std::path::PathBuf; use futures::channel::oneshot; use serde::Deserialize; -use tokio::sync::RwLock; +use tokio::sync::{Mutex, RwLock}; use crate::data::*; use crate::proto::*; @@ -18,10 +18,12 @@ use crate::table::*; pub struct Garage { pub db: sled::Db, pub system: Arc<System>, + pub fs_lock: Mutex<()>, pub table_rpc_handlers: HashMap<String, Box<dyn TableRpcHandler + Sync + Send>>, pub object_table: Arc<Table<ObjectTable>>, + pub version_table: Arc<Table<VersionTable>>, } impl Garage { @@ -41,19 +43,34 @@ impl Garage { &db, "object".to_string(), meta_rep_param.clone())); + let version_table = Arc::new(Table::new( + VersionTable{garage: RwLock::new(None)}, + system.clone(), + &db, + "version".to_string(), + meta_rep_param.clone())); let mut garage = Self{ db, system: system.clone(), + fs_lock: Mutex::new(()), table_rpc_handlers: HashMap::new(), object_table, + version_table, }; + garage.table_rpc_handlers.insert( garage.object_table.name.clone(), garage.object_table.clone().rpc_handler()); + garage.table_rpc_handlers.insert( + garage.version_table.name.clone(), + garage.version_table.clone().rpc_handler()); let garage = Arc::new(garage); + *garage.object_table.instance.garage.write().await = Some(garage.clone()); + *garage.version_table.instance.garage.write().await = Some(garage.clone()); + garage } } |