3
3
mod common;
4
4
5
5
use 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
+ } ;
7
10
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
+ ) {
9
15
let mut txn = client
10
16
. begin_optimistic ( )
11
17
. await
@@ -17,7 +23,7 @@ async fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>
17
23
txn. commit ( ) . await . expect ( "Could not commit transaction" ) ;
18
24
}
19
25
20
- async fn get ( client : & Client , key : Key ) -> Option < Value > {
26
+ async fn get < C : RequestCodec > ( client : & Client < C > , key : Key ) -> Option < Value > {
21
27
let mut txn = client
22
28
. begin_optimistic ( )
23
29
. await
@@ -29,7 +35,7 @@ async fn get(client: &Client, key: Key) -> Option<Value> {
29
35
res
30
36
}
31
37
32
- async fn key_exists ( client : & Client , key : Key ) -> bool {
38
+ async fn key_exists < C : RequestCodec > ( client : & Client < C > , key : Key ) -> bool {
33
39
let mut txn = client
34
40
. begin_optimistic ( )
35
41
. await
@@ -44,7 +50,7 @@ async fn key_exists(client: &Client, key: Key) -> bool {
44
50
res
45
51
}
46
52
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 ) {
48
54
let mut txn = client
49
55
. begin_optimistic ( )
50
56
. await
@@ -56,7 +62,7 @@ async fn scan(client: &Client, range: impl Into<BoundRange>, limit: u32) {
56
62
txn. commit ( ) . await . expect ( "Could not commit transaction" ) ;
57
63
}
58
64
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 > ) {
60
66
let mut txn = client
61
67
. begin_optimistic ( )
62
68
. await
@@ -81,7 +87,7 @@ async fn main() {
81
87
Config :: default ( )
82
88
} ;
83
89
84
- let txn = Client :: new_with_config ( args. pd , config, None )
90
+ let txn = Client :: new_with_config ( args. pd , config, TxnApiV1 , None )
85
91
. await
86
92
. expect ( "Could not connect to tikv" ) ;
87
93
0 commit comments