Keep network status & ring in a tokio::sync::watch

advantages
- reads don't prevent preparing writes
- can be followed from other parts of the system by cloning the receiver
This commit is contained in:
Alex Auvolat
2020-04-11 23:53:32 +02:00
parent 5dd59e437d
commit 9c931f5eda
9 changed files with 165 additions and 133 deletions
+6 -6
View File
@@ -212,9 +212,9 @@ async fn put_block_meta(
async fn put_block(garage: Arc<Garage>, hash: Hash, data: Vec<u8>) -> Result<(), Error> {
let who = garage
.system
.members
.read()
.await
.ring
.borrow()
.clone()
.walk_ring(&hash, garage.system.config.meta_replication_factor);
rpc_try_call_many(
garage.system.clone(),
@@ -359,9 +359,9 @@ async fn handle_get(
async fn get_block(garage: Arc<Garage>, hash: &Hash) -> Result<Vec<u8>, Error> {
let who = garage
.system
.members
.read()
.await
.ring
.borrow()
.clone()
.walk_ring(&hash, garage.system.config.meta_replication_factor);
let resps = rpc_try_call_many(
garage.system.clone(),