parent
c3bb2b62a8
commit
92fea414d9
4 changed files with 181 additions and 51 deletions
|
@ -1,6 +1,4 @@
|
||||||
#![feature(async_fn_in_trait)]
|
#![feature(async_fn_in_trait)]
|
||||||
#![feature(return_position_impl_trait_in_trait)]
|
|
||||||
// should be stabilized soon https://github.com/rust-lang/rust/pull/115822
|
|
||||||
|
|
||||||
mod bayou;
|
mod bayou;
|
||||||
mod config;
|
mod config;
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
use crate::storage::*;
|
||||||
|
|
||||||
|
pub struct GrgCreds {}
|
||||||
|
pub struct GrgStore {}
|
||||||
|
pub struct GrgRef {}
|
||||||
|
pub struct GrgValue {}
|
||||||
|
|
||||||
|
pub struct GrgTypes {}
|
||||||
|
impl RowRealization for GrgTypes {
|
||||||
|
type Store=GrgStore;
|
||||||
|
type Ref=GrgRef;
|
||||||
|
type Value=GrgValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowBuilder<GrgTypes> for GrgCreds {
|
||||||
|
fn row_store(&self) -> GrgStore {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowStore<GrgTypes> for GrgStore {
|
||||||
|
fn new_row(&self, partition: &str, sort: &str) -> GrgRef {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowRef<GrgTypes> for GrgRef {
|
||||||
|
fn set_value(&self, content: Vec<u8>) -> GrgValue {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn fetch(&self) -> Result<GrgValue, Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn rm(&self) -> Result<(), Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn poll(&self) -> Result<Option<GrgValue>, Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowValue<GrgTypes> for GrgValue {
|
||||||
|
fn to_ref(&self) -> GrgRef {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
fn content(&self) -> ConcurrentValues {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn push(&self) -> Result<(), Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
/// A custom S3 region, composed of a region name and endpoint.
|
||||||
|
/// We use this instead of rusoto_signature::Region so that we can
|
||||||
|
/// derive Hash and Eq
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
||||||
|
pub struct Region {
|
||||||
|
pub name: String,
|
||||||
|
pub endpoint: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Region {
|
||||||
|
pub fn as_rusoto_region(&self) -> rusoto_signature::Region {
|
||||||
|
rusoto_signature::Region::Custom {
|
||||||
|
name: self.name.clone(),
|
||||||
|
endpoint: self.endpoint.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
pub struct Garage {
|
||||||
|
pub s3_region: Region,
|
||||||
|
pub k2v_region: Region,
|
||||||
|
|
||||||
|
pub aws_access_key_id: String,
|
||||||
|
pub aws_secret_access_key: String,
|
||||||
|
pub bucket: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StoreBuilder<> for Garage {
|
||||||
|
fn row_store(&self) ->
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct K2V {}
|
||||||
|
impl RowStore for K2V {
|
||||||
|
|
||||||
|
}*/
|
|
@ -0,0 +1,54 @@
|
||||||
|
use crate::storage::*;
|
||||||
|
|
||||||
|
pub struct MemCreds {}
|
||||||
|
pub struct MemStore {}
|
||||||
|
pub struct MemRef {}
|
||||||
|
pub struct MemValue {}
|
||||||
|
|
||||||
|
pub struct MemTypes {}
|
||||||
|
impl RowRealization for MemTypes {
|
||||||
|
type Store=MemStore;
|
||||||
|
type Ref=MemRef;
|
||||||
|
type Value=MemValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowBuilder<MemTypes> for MemCreds {
|
||||||
|
fn row_store(&self) -> MemStore {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowStore<MemTypes> for MemStore {
|
||||||
|
fn new_row(&self, partition: &str, sort: &str) -> MemRef {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowRef<MemTypes> for MemRef {
|
||||||
|
fn set_value(&self, content: Vec<u8>) -> MemValue {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn fetch(&self) -> Result<MemValue, Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn rm(&self) -> Result<(), Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn poll(&self) -> Result<Option<MemValue>, Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RowValue<MemTypes> for MemValue {
|
||||||
|
fn to_ref(&self) -> MemRef {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
fn content(&self) -> ConcurrentValues {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
async fn push(&self) -> Result<(), Error> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
* 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
|
* 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.
|
* 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;
|
mod garage;
|
||||||
|
|
||||||
pub enum Selector<'a> {
|
pub enum Selector<'a> {
|
||||||
|
@ -27,55 +22,42 @@ pub enum Alternative {
|
||||||
}
|
}
|
||||||
type ConcurrentValues = Vec<Alternative>;
|
type ConcurrentValues = Vec<Alternative>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
NotFound,
|
NotFound,
|
||||||
Internal,
|
Internal,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------ Store
|
pub trait RowRealization: Sized {
|
||||||
pub trait RowStore {
|
type Store: RowStore<Self>;
|
||||||
fn new_row(&self, partition: &str, sort: &str) -> impl RowRef;
|
type Ref: RowRef<Self>;
|
||||||
fn new_row_batch(&self, partition: &str, filter: Selector) -> impl RowRefBatch;
|
type Value: RowValue<Self>;
|
||||||
fn new_blob(&self, key: &str) -> impl BlobRef;
|
|
||||||
fn new_blob_list(&self) -> Vec<impl BlobRef>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------- Row
|
// ------ Row Builder
|
||||||
pub trait RowRef {
|
pub trait RowBuilder<R: RowRealization>
|
||||||
fn to_value(&self, content: &[u8]) -> impl RowValue;
|
{
|
||||||
async fn get(&self) -> Result<impl RowValue, Error>;
|
fn row_store(&self) -> R::Store;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------ Row Store
|
||||||
|
pub trait RowStore<R: RowRealization>
|
||||||
|
{
|
||||||
|
fn new_row(&self, partition: &str, sort: &str) -> R::Ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------- Row Item
|
||||||
|
pub trait RowRef<R: RowRealization>
|
||||||
|
{
|
||||||
|
fn set_value(&self, content: Vec<u8>) -> R::Value;
|
||||||
|
async fn fetch(&self) -> Result<R::Value, Error>;
|
||||||
async fn rm(&self) -> Result<(), Error>;
|
async fn rm(&self) -> Result<(), Error>;
|
||||||
async fn poll(&self) -> Result<Option<impl RowValue>, Error>;
|
async fn poll(&self) -> Result<Option<R::Value>, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait RowValue {
|
pub trait RowValue<R: RowRealization>
|
||||||
fn row_ref(&self) -> impl RowRef;
|
{
|
||||||
|
fn to_ref(&self) -> R::Ref;
|
||||||
fn content(&self) -> ConcurrentValues;
|
fn content(&self) -> ConcurrentValues;
|
||||||
async fn persist(&self) -> Result<(), Error>;
|
async fn push(&self) -> Result<(), Error>;
|
||||||
}
|
|
||||||
|
|
||||||
// ------ Row batch
|
|
||||||
pub trait RowRefBatch {
|
|
||||||
fn to_values(&self, content: Vec<&[u8]>) -> impl RowValueBatch;
|
|
||||||
fn into_independant(&self) -> Vec<impl RowRef>;
|
|
||||||
async fn get(&self) -> Result<impl RowValueBatch, Error>;
|
|
||||||
async fn rm(&self) -> Result<(), Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait RowValueBatch {
|
|
||||||
fn into_independant(&self) -> Vec<impl RowValue>;
|
|
||||||
fn content(&self) -> Vec<ConcurrentValues>;
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue