in-memory storage #32

Merged
quentin merged 65 commits from in-memory into main 2023-12-27 16:35:43 +00:00
4 changed files with 10 additions and 10 deletions
Showing only changes of commit 8cd9801030 - Show all commits

View file

@ -265,7 +265,7 @@ impl<S: BayouState> Bayou<S> {
);
self.k2v
.row(&self.path, &ts.to_string())
.set_value(seal_serialize(&op, &self.key)?)
.set_value(&seal_serialize(&op, &self.key)?)
.push()
.await?;
@ -500,7 +500,7 @@ impl K2vWatch {
}
_ = this.notify.notified() => {
let rand = u128::to_be_bytes(thread_rng().gen()).to_vec();
if let Err(e) = row.set_value(rand).push().await
if let Err(e) = row.set_value(&rand).push().await
{
error!("Error in bayou k2v watch updater loop: {}", e);
tokio::time::sleep(Duration::from_secs(30)).await;

View file

@ -104,11 +104,11 @@ impl LoginProvider for StaticLoginProvider {
bucket,
};*/
let storage: storage::Builders = match user.storage {
StaticStorage::InMemory => X,
StaticStorage::Garage => Y,
StaticStorage::InMemory => Box::new(storage::in_memory::FullMem {}),
StaticStorage::Garage(c) => Box::new(storage::garage::GrgCreds {}),
};
let k2v_client = storage.k2v_client()?;
let k2v_client = storage.row_store()?;
let (_, public_key) = CryptoKeys::load_salt_and_public(&k2v_client).await?;
Ok(PublicCredentials {

View file

@ -361,7 +361,7 @@ async fn k2v_lock_loop_internal(
Some(orphan) => k2v.from_orphan(orphan).expect("Source & target must be storage compatible"),
None => k2v.row(pk, sk),
};
if let Err(e) = row.set_value(lock).push().await {
if let Err(e) = row.set_value(&lock).push().await {
error!("Could not take lock: {}", e);
tokio::time::sleep(Duration::from_secs(30)).await;
}
@ -432,7 +432,7 @@ impl EncryptedMessage {
send.push().await?;
// Update watch key to signal new mail
watch_ct.set_value(gen_ident().0.to_vec()).push().await?;
watch_ct.set_value(gen_ident().0.as_ref()).push().await?;
Ok(())
}

View file

@ -282,7 +282,7 @@ impl MailboxInternal {
rfc822_size: mail.raw.len(),
};
let meta_blob = seal_serialize(&meta, &self.encryption_key)?;
self.k2v.row(&self.mail_path, &ident.to_string()).set_value(meta_blob).push().await?;
self.k2v.row(&self.mail_path, &ident.to_string()).set_value(&meta_blob).push().await?;
Ok::<_, anyhow::Error>(())
},
self.uid_index.opportunistic_sync()
@ -326,7 +326,7 @@ impl MailboxInternal {
rfc822_size: mail.raw.len(),
};
let meta_blob = seal_serialize(&meta, &self.encryption_key)?;
self.k2v.row(&self.mail_path, &ident.to_string()).set_value(meta_blob).push().await?;
self.k2v.row(&self.mail_path, &ident.to_string()).set_value(&meta_blob).push().await?;
Ok::<_, anyhow::Error>(())
},
self.uid_index.opportunistic_sync()
@ -410,7 +410,7 @@ impl MailboxInternal {
// Copy mail meta in K2V
let meta = &from.fetch_meta(&[source_id]).await?[0];
let meta_blob = seal_serialize(meta, &self.encryption_key)?;
self.k2v.row(&self.mail_path, &new_id.to_string()).set_value(meta_blob).push().await?;
self.k2v.row(&self.mail_path, &new_id.to_string()).set_value(&meta_blob).push().await?;
Ok::<_, anyhow::Error>(())
},
self.uid_index.opportunistic_sync(),