Skip to content

Commit

Permalink
Merge pull request #5030 from lichuang/transaction_api
Browse files Browse the repository at this point in the history
Feature: transaction api
  • Loading branch information
mergify[bot] authored Apr 26, 2022
2 parents d947b2b + 80a31c6 commit 66e5104
Show file tree
Hide file tree
Showing 25 changed files with 979 additions and 33 deletions.
5 changes: 5 additions & 0 deletions common/management/tests/it/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use common_meta_types::Operation;
use common_meta_types::PasswordHashMethod;
use common_meta_types::PrefixListReply;
use common_meta_types::SeqV;
use common_meta_types::TxnReply;
use common_meta_types::TxnRequest;
use common_meta_types::UpsertKVAction;
use common_meta_types::UpsertKVActionReply;
use common_meta_types::UserIdentity;
Expand All @@ -53,6 +55,9 @@ mock! {
) -> Result<MGetKVActionReply,MetaError>;

async fn prefix_list_kv(&self, prefix: &str) -> Result<PrefixListReply, MetaError>;

async fn transaction(&self, txn: TxnRequest) -> Result<TxnReply, MetaError>;

}
}

Expand Down
8 changes: 8 additions & 0 deletions common/meta/api/src/kv_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use common_meta_types::GetKVActionReply;
use common_meta_types::MGetKVActionReply;
use common_meta_types::MetaError;
use common_meta_types::PrefixListReply;
use common_meta_types::TxnReply;
use common_meta_types::TxnRequest;
use common_meta_types::UpsertKVAction;
use common_meta_types::UpsertKVActionReply;

Expand All @@ -44,6 +46,8 @@ pub trait KVApi: Send + Sync {
async fn mget_kv(&self, key: &[String]) -> Result<MGetKVActionReply, MetaError>;

async fn prefix_list_kv(&self, prefix: &str) -> Result<PrefixListReply, MetaError>;

async fn transaction(&self, txn: TxnRequest) -> Result<TxnReply, MetaError>;
}

#[async_trait]
Expand All @@ -63,4 +67,8 @@ impl<U: KVApi, T: Deref<Target = U> + Send + Sync> KVApi for T {
async fn prefix_list_kv(&self, prefix: &str) -> Result<PrefixListReply, MetaError> {
self.deref().prefix_list_kv(prefix).await
}

async fn transaction(&self, txn: TxnRequest) -> Result<TxnReply, MetaError> {
self.deref().transaction(txn).await
}
}
Loading

0 comments on commit 66e5104

Please sign in to comment.