Skip to content

Commit

Permalink
feat: multi-action transaction support with retries (#8)
Browse files Browse the repository at this point in the history
* feat: multi-action transaction support with retries

* fix: get rid of move and unnecessary cloning

* chore: remove unnecessary clones

* fix: clippy warnings solved

* chore: formatted
  • Loading branch information
bittermandel authored Oct 11, 2024
1 parent 1b3cc9c commit 9285b94
Show file tree
Hide file tree
Showing 7 changed files with 404 additions and 218 deletions.
14 changes: 7 additions & 7 deletions crates/valv/src/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl MasterKeyManagementService for API {
let key = self
.valv
.create_key(
request.get_ref().keyring_name.clone(),
request.get_ref().master_key_id.clone(),
&request.get_ref().keyring_name,
&request.get_ref().master_key_id,
)
.await;

Expand Down Expand Up @@ -101,8 +101,8 @@ impl MasterKeyManagementService for API {
let encrypted_value = self
.valv
.encrypt(
request.get_ref().keyring_name.clone(),
request.get_ref().master_key_id.clone(),
&request.get_ref().keyring_name,
&request.get_ref().master_key_id,
request.get_ref().plaintext.clone().to_vec(),
)
.await;
Expand Down Expand Up @@ -133,9 +133,9 @@ impl MasterKeyManagementService for API {
let decrypted_result = self
.valv
.decrypt(
request.get_ref().keyring_name.clone(),
request.get_ref().master_key_id.clone(),
request.get_ref().ciphertext.clone().to_vec(),
&request.get_ref().keyring_name,
&request.get_ref().master_key_id,
request.get_ref().ciphertext.to_vec(),
)
.await;
match decrypted_result {
Expand Down
23 changes: 9 additions & 14 deletions crates/valv/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
use foundationdb::FdbBindingError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ValvError {
#[error("IO error")]
Io(#[from] std::io::Error),

#[error("Database error")]
Database(#[from] foundationdb::FdbError),

#[error("Transaction commit error")]
TransactionCommitError(#[from] foundationdb::TransactionCommitError),

#[error("Directory error")]
DirectoryError(foundationdb::directory::DirectoryError),

#[error("TuplePacking error")]
TuplePacking(#[from] foundationdb::tuple::PackError),

#[error("Prost decode error")]
Decode(#[from] prost::DecodeError),
#[error("Storage error")]
Storage(#[from] crate::storage::errors::StorageError),

#[error("BoringSSL error")]
BoringSSL(#[from] boring::error::ErrorStack),
Expand All @@ -43,3 +32,9 @@ pub enum ValvError {
}

pub type Result<T> = std::result::Result<T, ValvError>;

impl From<ValvError> for FdbBindingError {
fn from(error: ValvError) -> Self {
FdbBindingError::CustomError(Box::new(error))
}
}
Loading

0 comments on commit 9285b94

Please sign in to comment.