2020-04-08 20:00:41 +00:00
|
|
|
use std::sync::Arc;
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
use async_trait::async_trait;
|
2020-04-08 21:01:49 +00:00
|
|
|
use tokio::sync::RwLock;
|
2020-04-08 20:00:41 +00:00
|
|
|
|
|
|
|
use crate::data::*;
|
|
|
|
use crate::table::*;
|
2020-04-08 21:01:49 +00:00
|
|
|
use crate::server::Garage;
|
2020-04-08 20:00:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
2020-04-09 14:16:27 +00:00
|
|
|
pub struct VersionMeta {
|
|
|
|
pub bucket: StringKey,
|
|
|
|
pub key: StringKey,
|
|
|
|
|
2020-04-08 20:00:41 +00:00
|
|
|
pub timestamp: u64,
|
|
|
|
pub uuid: UUID,
|
|
|
|
|
|
|
|
pub mime_type: String,
|
|
|
|
pub size: u64,
|
|
|
|
pub is_complete: bool,
|
|
|
|
|
|
|
|
pub data: VersionData,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub enum VersionData {
|
|
|
|
DeleteMarker,
|
|
|
|
Inline(#[serde(with="serde_bytes")] Vec<u8>),
|
|
|
|
FirstBlock(Hash),
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct VersionTable {
|
2020-04-08 21:01:49 +00:00
|
|
|
pub garage: RwLock<Option<Arc<Garage>>>,
|
2020-04-08 20:00:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 14:16:27 +00:00
|
|
|
impl Entry<StringKey, StringKey> for VersionMeta {
|
|
|
|
fn partition_key(&self) -> &StringKey {
|
|
|
|
&self.bucket
|
2020-04-08 20:00:41 +00:00
|
|
|
}
|
2020-04-09 14:16:27 +00:00
|
|
|
fn sort_key(&self) -> &StringKey {
|
|
|
|
&self.key
|
2020-04-08 21:47:34 +00:00
|
|
|
}
|
2020-04-09 14:16:27 +00:00
|
|
|
|
2020-04-08 20:00:41 +00:00
|
|
|
fn merge(&mut self, other: &Self) {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl TableFormat for VersionTable {
|
2020-04-09 14:16:27 +00:00
|
|
|
type P = StringKey;
|
|
|
|
type S = StringKey;
|
|
|
|
type E = VersionMeta;
|
2020-04-08 20:00:41 +00:00
|
|
|
|
2020-04-09 14:16:27 +00:00
|
|
|
async fn updated(&self, old: Option<&Self::E>, new: &Self::E) {
|
2020-04-08 20:00:41 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|