aboutsummaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-08 23:01:49 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-08 23:01:49 +0200
commitcc580da0aef95bcb94bd2ce602258d0d18388969 (patch)
treec61148b75627dc27989d4ce39ded3b6124c86cfb /src/server.rs
parentbacc76a057bcd90d61bfe3584bd3cdbadc748364 (diff)
downloadgarage-cc580da0aef95bcb94bd2ce602258d0d18388969.tar.gz
garage-cc580da0aef95bcb94bd2ce602258d0d18388969.zip
Some work
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server.rs b/src/server.rs
index 31f1cc28..1f1ac2af 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -5,6 +5,7 @@ use std::net::SocketAddr;
use std::path::PathBuf;
use futures::channel::oneshot;
use serde::Deserialize;
+use tokio::sync::RwLock;
use crate::data::*;
use crate::proto::*;
@@ -24,7 +25,7 @@ pub struct Garage {
}
impl Garage {
- pub fn new(config: Config, id: UUID, db: sled::Db) -> Self {
+ pub async fn new(config: Config, id: UUID, db: sled::Db) -> Arc<Self> {
let system = Arc::new(System::new(config, id));
let meta_rep_param = TableReplicationParams{
@@ -35,6 +36,7 @@ impl Garage {
};
let version_table = Arc::new(Table::new(
+ VersionTable{garage: RwLock::new(None)},
system.clone(),
&db,
"version".to_string(),
@@ -49,6 +51,9 @@ impl Garage {
garage.table_rpc_handlers.insert(
garage.version_table.name.clone(),
garage.version_table.clone().rpc_handler());
+
+ let garage = Arc::new(garage);
+ *garage.version_table.instance.garage.write().await = Some(garage.clone());
garage
}
}
@@ -139,7 +144,7 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
.expect("Unable to read or generate node ID");
println!("Node ID: {}", hex::encode(&id));
- let garage = Arc::new(Garage::new(config, id, db));
+ let garage = Garage::new(config, id, db).await;
let (tx1, rx1) = oneshot::channel();
let (tx2, rx2) = oneshot::channel();