33mod common;
44
55use crate :: common:: parse_args;
6- use tikv_client:: { BoundRange , Config , Key , KvPair , TransactionClient as Client , Value } ;
6+ use tikv_client:: {
7+ request:: request_codec:: { RequestCodec , TxnApiV1 } ,
8+ BoundRange , Config , Key , KvPair , TransactionClient as Client , Value ,
9+ } ;
710
8- async fn puts ( client : & Client , pairs : impl IntoIterator < Item = impl Into < KvPair > > ) {
11+ async fn puts < C : RequestCodec > (
12+ client : & Client < C > ,
13+ pairs : impl IntoIterator < Item = impl Into < KvPair > > ,
14+ ) {
915 let mut txn = client
1016 . begin_optimistic ( )
1117 . await
@@ -17,7 +23,7 @@ async fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>
1723 txn. commit ( ) . await . expect ( "Could not commit transaction" ) ;
1824}
1925
20- async fn get ( client : & Client , key : Key ) -> Option < Value > {
26+ async fn get < C : RequestCodec > ( client : & Client < C > , key : Key ) -> Option < Value > {
2127 let mut txn = client
2228 . begin_optimistic ( )
2329 . await
@@ -29,7 +35,7 @@ async fn get(client: &Client, key: Key) -> Option<Value> {
2935 res
3036}
3137
32- async fn key_exists ( client : & Client , key : Key ) -> bool {
38+ async fn key_exists < C : RequestCodec > ( client : & Client < C > , key : Key ) -> bool {
3339 let mut txn = client
3440 . begin_optimistic ( )
3541 . await
@@ -44,7 +50,7 @@ async fn key_exists(client: &Client, key: Key) -> bool {
4450 res
4551}
4652
47- async fn scan ( client : & Client , range : impl Into < BoundRange > , limit : u32 ) {
53+ async fn scan < C : RequestCodec > ( client : & Client < C > , range : impl Into < BoundRange > , limit : u32 ) {
4854 let mut txn = client
4955 . begin_optimistic ( )
5056 . await
@@ -56,7 +62,7 @@ async fn scan(client: &Client, range: impl Into<BoundRange>, limit: u32) {
5662 txn. commit ( ) . await . expect ( "Could not commit transaction" ) ;
5763}
5864
59- async fn dels ( client : & Client , keys : impl IntoIterator < Item = Key > ) {
65+ async fn dels < C : RequestCodec > ( client : & Client < C > , keys : impl IntoIterator < Item = Key > ) {
6066 let mut txn = client
6167 . begin_optimistic ( )
6268 . await
@@ -81,7 +87,7 @@ async fn main() {
8187 Config :: default ( )
8288 } ;
8389
84- let txn = Client :: new_with_config ( args. pd , config, None )
90+ let txn = Client :: new_with_config ( args. pd , config, TxnApiV1 , None )
8591 . await
8692 . expect ( "Could not connect to tikv" ) ;
8793
0 commit comments