mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-07 21:33:13 +00:00
New buckets for 0.6.0: make bucket id a SK and not a HK, CLI updates
This commit is contained in:
@@ -105,15 +105,29 @@ impl Bucket {
|
||||
crdt::Deletable::Present(state) => state.authorized_keys.items(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn aliases(&self) -> &[(String, u64, bool)] {
|
||||
match &self.state {
|
||||
crdt::Deletable::Deleted => &[],
|
||||
crdt::Deletable::Present(state) => state.aliases.items(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn local_aliases(&self) -> &[((String, String), u64, bool)] {
|
||||
match &self.state {
|
||||
crdt::Deletable::Deleted => &[],
|
||||
crdt::Deletable::Present(state) => state.local_aliases.items(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Entry<Uuid, EmptyKey> for Bucket {
|
||||
fn partition_key(&self) -> &Uuid {
|
||||
&self.id
|
||||
}
|
||||
fn sort_key(&self) -> &EmptyKey {
|
||||
impl Entry<EmptyKey, Uuid> for Bucket {
|
||||
fn partition_key(&self) -> &EmptyKey {
|
||||
&EmptyKey
|
||||
}
|
||||
fn sort_key(&self) -> &Uuid {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
|
||||
impl Crdt for Bucket {
|
||||
@@ -127,8 +141,8 @@ pub struct BucketTable;
|
||||
impl TableSchema for BucketTable {
|
||||
const TABLE_NAME: &'static str = "bucket_v2";
|
||||
|
||||
type P = Uuid;
|
||||
type S = EmptyKey;
|
||||
type P = EmptyKey;
|
||||
type S = Uuid;
|
||||
type E = Bucket;
|
||||
type Filter = DeletedFilter;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ impl<'a> BucketHelper<'a> {
|
||||
Ok(self
|
||||
.0
|
||||
.bucket_table
|
||||
.get(&bucket_id, &EmptyKey)
|
||||
.get(&EmptyKey, &bucket_id)
|
||||
.await?
|
||||
.filter(|x| !x.state.is_deleted())
|
||||
.map(|_| bucket_id))
|
||||
@@ -58,7 +58,7 @@ impl<'a> BucketHelper<'a> {
|
||||
Ok(self
|
||||
.0
|
||||
.bucket_table
|
||||
.get(&bucket_id, &EmptyKey)
|
||||
.get(&EmptyKey, &bucket_id)
|
||||
.await?
|
||||
.ok_or_message(format!("Bucket {:?} does not exist", bucket_id))?)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ impl<'a> BucketHelper<'a> {
|
||||
pub async fn get_existing_bucket(&self, bucket_id: Uuid) -> Result<Bucket, Error> {
|
||||
self.0
|
||||
.bucket_table
|
||||
.get(&bucket_id, &EmptyKey)
|
||||
.get(&EmptyKey, &bucket_id)
|
||||
.await?
|
||||
.filter(|b| !b.is_deleted())
|
||||
.ok_or_bad_request(format!(
|
||||
|
||||
Reference in New Issue
Block a user