aboutsummaryrefslogtreecommitdiff
path: root/src/table/sync.rs
diff options
context:
space:
mode:
authorTrinity Pointard <trinity.pointard@gmail.com>2021-04-23 21:42:52 +0200
committerAlex Auvolat <alex@adnab.me>2021-05-03 22:11:41 +0200
commitf5a0cf0414fc3db7affcbe7ffcf4e251a2afd192 (patch)
tree12c225c9456f18d96cf8a587ce9a308f433da9e7 /src/table/sync.rs
parentf05bb111c2e7dd77f2b34b82892bbfa8e6a063c1 (diff)
downloadgarage-f5a0cf0414fc3db7affcbe7ffcf4e251a2afd192.tar.gz
garage-f5a0cf0414fc3db7affcbe7ffcf4e251a2afd192.zip
fix clippy warnings on table
Diffstat (limited to 'src/table/sync.rs')
-rw-r--r--src/table/sync.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/table/sync.rs b/src/table/sync.rs
index 3130abe8..33b01455 100644
--- a/src/table/sync.rs
+++ b/src/table/sync.rs
@@ -150,14 +150,12 @@ where
if let Some(busy) = busy_opt {
if busy {
nothing_to_do_since = None;
- } else {
- if nothing_to_do_since.is_none() {
- nothing_to_do_since = Some(Instant::now());
- }
+ } else if nothing_to_do_since.is_none() {
+ nothing_to_do_since = Some(Instant::now());
}
}
}
- _ = must_exit.changed().fuse() => (),
+ _ = must_exit.changed().fuse() => {},
_ = tokio::time::sleep(Duration::from_secs(1)).fuse() => {
if nothing_to_do_since.map(|t| Instant::now() - t >= ANTI_ENTROPY_INTERVAL).unwrap_or(false) {
nothing_to_do_since = None;
@@ -277,7 +275,7 @@ where
}
}
- if items.len() > 0 {
+ if !items.is_empty() {
let nodes = self
.data
.replication
@@ -292,9 +290,10 @@ where
break;
}
if nodes.len() < self.data.replication.write_quorum() {
- return Err(Error::Message(format!(
+ return Err(Error::Message(
"Not offloading as we don't have a quorum of nodes to write to."
- )));
+ .to_string(),
+ ));
}
counter += 1;
@@ -317,14 +316,14 @@ where
async fn offload_items(
self: &Arc<Self>,
- items: &Vec<(Vec<u8>, Arc<ByteBuf>)>,
+ items: &[(Vec<u8>, Arc<ByteBuf>)],
nodes: &[UUID],
) -> Result<(), Error> {
let values = items.iter().map(|(_k, v)| v.clone()).collect::<Vec<_>>();
self.rpc_client
.try_call_many(
- &nodes[..],
+ nodes,
SyncRPC::Items(values),
RequestStrategy::with_quorum(nodes.len()).with_timeout(TABLE_SYNC_RPC_TIMEOUT),
)
@@ -467,7 +466,7 @@ where
}
if todo_items.len() >= 256 {
- self.send_items(who, std::mem::replace(&mut todo_items, vec![]))
+ self.send_items(who, std::mem::take(&mut todo_items))
.await?;
}
}
@@ -523,7 +522,7 @@ where
self.data.update_many(items)?;
Ok(SyncRPC::Ok)
}
- _ => Err(Error::Message(format!("Unexpected sync RPC"))),
+ _ => Err(Error::Message("Unexpected sync RPC".to_string())),
}
}
}