diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-10 22:01:48 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-10 22:01:48 +0200 |
commit | 3477864142ed09c36abea1111937b829fb41c8a4 (patch) | |
tree | d95221e66b9c014af7f4dba61ae4ff113c0e409a /src/object_table.rs | |
parent | d66c0d6833ddbeb61e34ee222dde92a5363bda1f (diff) | |
download | garage-3477864142ed09c36abea1111937b829fb41c8a4.tar.gz garage-3477864142ed09c36abea1111937b829fb41c8a4.zip |
Fix the Sync issue. Details:
So the HTTP client future of Hyper is not Sync, thus the stream
that read blocks wasn't either. However Hyper's default Body type
requires a stream to be Sync for wrap_stream. Solution: reimplement
a custom HTTP body type.
Diffstat (limited to 'src/object_table.rs')
-rw-r--r-- | src/object_table.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/object_table.rs b/src/object_table.rs index 37b9fc0a..392e0dc7 100644 --- a/src/object_table.rs +++ b/src/object_table.rs @@ -1,12 +1,11 @@ -use std::sync::Arc; -use serde::{Serialize, Deserialize}; use async_trait::async_trait; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; use tokio::sync::RwLock; use crate::data::*; -use crate::table::*; use crate::server::Garage; - +use crate::table::*; #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] pub struct Object { @@ -35,7 +34,7 @@ pub struct ObjectVersion { #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] pub enum ObjectVersionData { DeleteMarker, - Inline(#[serde(with="serde_bytes")] Vec<u8>), + Inline(#[serde(with = "serde_bytes")] Vec<u8>), FirstBlock(Hash), } @@ -49,7 +48,9 @@ impl Entry<String, String> for Object { fn merge(&mut self, other: &Self) { for other_v in other.versions.iter() { - match self.versions.binary_search_by(|v| (v.timestamp, &v.uuid).cmp(&(other_v.timestamp, &other_v.uuid))) { + match self.versions.binary_search_by(|v| { + (v.timestamp, &v.uuid).cmp(&(other_v.timestamp, &other_v.uuid)) + }) { Ok(i) => { let mut v = &mut self.versions[i]; if other_v.size > v.size { @@ -64,8 +65,11 @@ impl Entry<String, String> for Object { } } } - let last_complete = self.versions - .iter().enumerate().rev() + let last_complete = self + .versions + .iter() + .enumerate() + .rev() .filter(|(_, v)| v.is_complete) .next() .map(|(vi, _)| vi); |