aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2022-05-10 13:16:57 +0200
committerAlex <alex@adnab.me>2022-05-10 13:16:57 +0200
commit5768bf362262f78376af14517c4921941986192e (patch)
treeb4baf3051eade0f63649443278bb3a3f4c38ec25 /src/util
parentdef78c5e6f5da37a0d17b5652c525fbeccbc2e86 (diff)
downloadgarage-5768bf362262f78376af14517c4921941986192e.tar.gz
garage-5768bf362262f78376af14517c4921941986192e.zip
First implementation of K2V (#293)
**Specification:** View spec at [this URL](https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/k2v/doc/drafts/k2v-spec.md) - [x] Specify the structure of K2V triples - [x] Specify the DVVS format used for causality detection - [x] Specify the K2V index (just a counter of number of values per partition key) - [x] Specify single-item endpoints: ReadItem, InsertItem, DeleteItem - [x] Specify index endpoint: ReadIndex - [x] Specify multi-item endpoints: InsertBatch, ReadBatch, DeleteBatch - [x] Move to JSON objects instead of tuples - [x] Specify endpoints for polling for updates on single values (PollItem) **Implementation:** - [x] Table for K2V items, causal contexts - [x] Indexing mechanism and table for K2V index - [x] Make API handlers a bit more generic - [x] K2V API endpoint - [x] K2V API router - [x] ReadItem - [x] InsertItem - [x] DeleteItem - [x] PollItem - [x] ReadIndex - [x] InsertBatch - [x] ReadBatch - [x] DeleteBatch **Testing:** - [x] Just a simple Python script that does some requests to check visually that things are going right (does not contain parsing of results or assertions on returned values) - [x] Actual tests: - [x] Adapt testing framework - [x] Simple test with InsertItem + ReadItem - [x] Test with several Insert/Read/DeleteItem + ReadIndex - [x] Test all combinations of return formats for ReadItem - [x] Test with ReadBatch, InsertBatch, DeleteBatch - [x] Test with PollItem - [x] Test error codes - [ ] Fix most broken stuff - [x] test PollItem broken randomly - [x] when invalid causality tokens are given, errors should be 4xx not 5xx **Improvements:** - [x] Descending range queries - [x] Specify - [x] Implement - [x] Add test - [x] Batch updates to index counter - [x] Put K2V behind `k2v` feature flag Co-authored-by: Alex Auvolat <alex@adnab.me> Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/293 Co-authored-by: Alex <alex@adnab.me> Co-committed-by: Alex <alex@adnab.me>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Cargo.toml3
-rw-r--r--src/util/config.rs16
-rw-r--r--src/util/error.rs3
3 files changed, 20 insertions, 2 deletions
diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml
index f13c1589..95cde531 100644
--- a/src/util/Cargo.toml
+++ b/src/util/Cargo.toml
@@ -41,3 +41,6 @@ http = "0.2"
hyper = "0.14"
opentelemetry = { version = "0.17", features = [ "rt-tokio", "metrics", "trace" ] }
+
+[features]
+k2v = []
diff --git a/src/util/config.rs b/src/util/config.rs
index e4d96476..4d66bfe4 100644
--- a/src/util/config.rs
+++ b/src/util/config.rs
@@ -73,7 +73,11 @@ pub struct Config {
pub sled_flush_every_ms: u64,
/// Configuration for S3 api
- pub s3_api: ApiConfig,
+ pub s3_api: S3ApiConfig,
+
+ /// Configuration for K2V api
+ #[cfg(feature = "k2v")]
+ pub k2v_api: Option<K2VApiConfig>,
/// Configuration for serving files as normal web server
pub s3_web: WebConfig,
@@ -85,7 +89,7 @@ pub struct Config {
/// Configuration for S3 api
#[derive(Deserialize, Debug, Clone)]
-pub struct ApiConfig {
+pub struct S3ApiConfig {
/// Address and port to bind for api serving
pub api_bind_addr: SocketAddr,
/// S3 region to use
@@ -95,6 +99,14 @@ pub struct ApiConfig {
pub root_domain: Option<String>,
}
+/// Configuration for K2V api
+#[cfg(feature = "k2v")]
+#[derive(Deserialize, Debug, Clone)]
+pub struct K2VApiConfig {
+ /// Address and port to bind for api serving
+ pub api_bind_addr: SocketAddr,
+}
+
/// Configuration for serving files as normal web server
#[derive(Deserialize, Debug, Clone)]
pub struct WebConfig {
diff --git a/src/util/error.rs b/src/util/error.rs
index bdb3a69b..8734a0c8 100644
--- a/src/util/error.rs
+++ b/src/util/error.rs
@@ -44,6 +44,9 @@ pub enum Error {
#[error(display = "Tokio semaphore acquire error: {}", _0)]
TokioSemAcquire(#[error(source)] tokio::sync::AcquireError),
+ #[error(display = "Tokio broadcast receive error: {}", _0)]
+ TokioBcastRecv(#[error(source)] tokio::sync::broadcast::error::RecvError),
+
#[error(display = "Remote error: {}", _0)]
RemoteError(String),