From 92fea414d9d113761b788e409a025ad9cff06071 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 1 Nov 2023 15:15:57 +0100 Subject: v2 api storage --- src/storage/mod.rs | 74 +++++++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 46 deletions(-) (limited to 'src/storage/mod.rs') diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 6b410a2..4ef2d61 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -1,19 +1,14 @@ /* - * T1 : Filter - * T2 : Range - * T3 : Atom - */ - -/* - * My idea: we can encapsulate the causality token - * into the object system so it is not exposed. * * This abstraction goal is to leverage all the semantic of Garage K2V+S3, * to be as tailored as possible to it ; it aims to be a zero-cost abstraction * compared to when we where directly using the K2V+S3 client. + * + * My idea: we can encapsulate the causality token + * into the object system so it is not exposed. */ - +mod in_memory; mod garage; pub enum Selector<'a> { @@ -27,55 +22,42 @@ pub enum Alternative { } type ConcurrentValues = Vec; +#[derive(Debug)] pub enum Error { NotFound, Internal, } -// ------ Store -pub trait RowStore { - fn new_row(&self, partition: &str, sort: &str) -> impl RowRef; - fn new_row_batch(&self, partition: &str, filter: Selector) -> impl RowRefBatch; - fn new_blob(&self, key: &str) -> impl BlobRef; - fn new_blob_list(&self) -> Vec; +pub trait RowRealization: Sized { + type Store: RowStore; + type Ref: RowRef; + type Value: RowValue; } -// ------- Row -pub trait RowRef { - fn to_value(&self, content: &[u8]) -> impl RowValue; - async fn get(&self) -> Result; - async fn rm(&self) -> Result<(), Error>; - async fn poll(&self) -> Result, Error>; +// ------ Row Builder +pub trait RowBuilder +{ + fn row_store(&self) -> R::Store; } -pub trait RowValue { - fn row_ref(&self) -> impl RowRef; - fn content(&self) -> ConcurrentValues; - async fn persist(&self) -> Result<(), Error>; +// ------ Row Store +pub trait RowStore +{ + fn new_row(&self, partition: &str, sort: &str) -> R::Ref; } -// ------ Row batch -pub trait RowRefBatch { - fn to_values(&self, content: Vec<&[u8]>) -> impl RowValueBatch; - fn into_independant(&self) -> Vec; - async fn get(&self) -> Result; +// ------- Row Item +pub trait RowRef +{ + fn set_value(&self, content: Vec) -> R::Value; + async fn fetch(&self) -> Result; async fn rm(&self) -> Result<(), Error>; + async fn poll(&self) -> Result, Error>; } -pub trait RowValueBatch { - fn into_independant(&self) -> Vec; - fn content(&self) -> Vec; - async fn persist(&self) -> Result<(), Error>; -} - -// ----- Blobs -pub trait BlobRef { - fn set_value(&self, content: &[u8]) -> impl BlobValue; - async fn get(&self) -> impl BlobValue; - async fn copy(&self, dst: &impl BlobRef) -> (); - async fn rm(&self, key: &str) -> (); -} - -pub trait BlobValue { - async fn persist(); +pub trait RowValue +{ + fn to_ref(&self) -> R::Ref; + fn content(&self) -> ConcurrentValues; + async fn push(&self) -> Result<(), Error>; } -- cgit v1.2.3