aboutsummaryrefslogtreecommitdiff
path: root/src/table
diff options
context:
space:
mode:
Diffstat (limited to 'src/table')
-rw-r--r--src/table/Cargo.toml32
-rw-r--r--src/table/lib.rs (renamed from src/table/mod.rs)5
-rw-r--r--src/table/table.rs20
-rw-r--r--src/table/table_fullcopy.rs7
-rw-r--r--src/table/table_sharded.rs7
-rw-r--r--src/table/table_sync.rs9
6 files changed, 60 insertions, 20 deletions
diff --git a/src/table/Cargo.toml b/src/table/Cargo.toml
new file mode 100644
index 00000000..714d0a6e
--- /dev/null
+++ b/src/table/Cargo.toml
@@ -0,0 +1,32 @@
+[package]
+name = "garage_table"
+version = "0.1.0"
+authors = ["Alex Auvolat <alex@adnab.me>"]
+edition = "2018"
+
+[lib]
+path = "lib.rs"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+garage_util = { path = "../util" }
+garage_rpc = { path = "../rpc" }
+
+bytes = "0.4"
+rand = "0.7"
+hex = "0.3"
+arc-swap = "0.4"
+log = "0.4"
+
+sled = "0.31"
+
+rmp-serde = "0.14.3"
+serde = { version = "1.0", default-features = false, features = ["derive", "rc"] }
+serde_bytes = "0.11"
+
+async-trait = "0.1.30"
+futures = "0.3"
+futures-util = "0.3"
+tokio = { version = "0.2", default-features = false, features = ["rt-core", "rt-threaded", "io-driver", "net", "tcp", "time", "macros", "sync", "signal", "fs"] }
+
diff --git a/src/table/mod.rs b/src/table/lib.rs
index e03b8d0b..f490b491 100644
--- a/src/table/mod.rs
+++ b/src/table/lib.rs
@@ -1,3 +1,8 @@
+#![recursion_limit = "1024"]
+
+#[macro_use]
+extern crate log;
+
pub mod table;
pub mod table_fullcopy;
pub mod table_sharded;
diff --git a/src/table/table.rs b/src/table/table.rs
index 50e8739a..94bacc60 100644
--- a/src/table/table.rs
+++ b/src/table/table.rs
@@ -8,14 +8,14 @@ use futures::stream::*;
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
-use crate::data::*;
-use crate::error::Error;
+use garage_util::data::*;
+use garage_util::error::Error;
-use crate::rpc::membership::{Ring, System};
-use crate::rpc::rpc_client::*;
-use crate::rpc::rpc_server::*;
+use garage_rpc::membership::{Ring, System};
+use garage_rpc::rpc_client::*;
+use garage_rpc::rpc_server::*;
-use crate::table::table_sync::*;
+use crate::table_sync::*;
const TABLE_RPC_TIMEOUT: Duration = Duration::from_secs(10);
@@ -78,14 +78,14 @@ impl PartitionKey for EmptyKey {
}
}
-impl<T: AsRef<str>> PartitionKey for T {
+impl PartitionKey for String {
fn hash(&self) -> Hash {
- hash(self.as_ref().as_bytes())
+ hash(self.as_bytes())
}
}
-impl<T: AsRef<str>> SortKey for T {
+impl SortKey for String {
fn sort_key(&self) -> &[u8] {
- self.as_ref().as_bytes()
+ self.as_bytes()
}
}
diff --git a/src/table/table_fullcopy.rs b/src/table/table_fullcopy.rs
index 2cd2e464..a6c78a63 100644
--- a/src/table/table_fullcopy.rs
+++ b/src/table/table_fullcopy.rs
@@ -1,9 +1,10 @@
use arc_swap::ArcSwapOption;
use std::sync::Arc;
-use crate::data::*;
-use crate::rpc::membership::{Ring, System};
-use crate::table::*;
+use garage_rpc::membership::{Ring, System};
+use garage_util::data::*;
+
+use crate::*;
#[derive(Clone)]
pub struct TableFullReplication {
diff --git a/src/table/table_sharded.rs b/src/table/table_sharded.rs
index 5190f5d4..88856542 100644
--- a/src/table/table_sharded.rs
+++ b/src/table/table_sharded.rs
@@ -1,6 +1,7 @@
-use crate::data::*;
-use crate::rpc::membership::{Ring, System};
-use crate::table::*;
+use garage_rpc::membership::{Ring, System};
+use garage_util::data::*;
+
+use crate::*;
#[derive(Clone)]
pub struct TableShardedReplication {
diff --git a/src/table/table_sync.rs b/src/table/table_sync.rs
index 8f6582a7..145b3068 100644
--- a/src/table/table_sync.rs
+++ b/src/table/table_sync.rs
@@ -12,10 +12,11 @@ use serde_bytes::ByteBuf;
use tokio::sync::Mutex;
use tokio::sync::{mpsc, watch};
-use crate::data::*;
-use crate::error::Error;
-use crate::rpc::membership::Ring;
-use crate::table::*;
+use garage_rpc::membership::Ring;
+use garage_util::data::*;
+use garage_util::error::Error;
+
+use crate::*;
const MAX_DEPTH: usize = 16;
const SCAN_INTERVAL: Duration = Duration::from_secs(3600);