@@ -19,7 +19,8 @@ const MAX_RAW_KV_SCAN_LIMIT: u32 = 10240;
19
19
/// Raw requests don't need a wrapping transaction.
20
20
/// Each request is immediately processed once executed.
21
21
///
22
- /// The returned results of raw requests are [`Future`](std::future::Future)s that must be awaited to execute.
22
+ /// The returned results of raw request methods are [`Future`](std::future::Future)s that must be
23
+ /// awaited to execute.
23
24
#[ derive( Clone ) ]
24
25
pub struct Client {
25
26
rpc : Arc < PdRpcClient > ,
@@ -29,14 +30,16 @@ pub struct Client {
29
30
}
30
31
31
32
impl Client {
32
- /// Create a raw [`Client`](Client) .
33
+ /// Create a raw [`Client`] and connect to the TiKV cluster .
33
34
///
34
- /// It's important to **include more than one PD endpoint** (include all, if possible!)
35
- /// This helps avoid having a *single point of failure*.
35
+ /// Because TiKV is managed by a [PD](https://github.com/pingcap/pd/) cluster, the endpoints for
36
+ /// PD must be provided, not the TiKV nodes. It's important to include more than one PD endpoint
37
+ /// (include all endpoints, if possible), this helps avoid having a single point of failure.
36
38
///
37
39
/// # Examples
40
+ ///
38
41
/// ```rust,no_run
39
- /// # use tikv_client::{Config, RawClient} ;
42
+ /// # use tikv_client::RawClient;
40
43
/// # use futures::prelude::*;
41
44
/// # futures::executor::block_on(async {
42
45
/// let client = RawClient::new(vec!["192.168.0.100"]).await.unwrap();
@@ -46,17 +49,23 @@ impl Client {
46
49
Self :: new_with_config ( pd_endpoints, Config :: default ( ) ) . await
47
50
}
48
51
49
- /// Create a raw [`Client`](Client) .
52
+ /// Create a raw [`Client`] with a custom configuration, and connect to the TiKV cluster .
50
53
///
51
- /// It's important to **include more than one PD endpoint** (include all, if possible!)
52
- /// This helps avoid having a *single point of failure*.
54
+ /// Because TiKV is managed by a [PD](https://github.com/pingcap/pd/) cluster, the endpoints for
55
+ /// PD must be provided, not the TiKV nodes. It's important to include more than one PD endpoint
56
+ /// (include all endpoints, if possible), this helps avoid having a single point of failure.
53
57
///
54
58
/// # Examples
59
+ ///
55
60
/// ```rust,no_run
56
61
/// # use tikv_client::{Config, RawClient};
57
62
/// # use futures::prelude::*;
63
+ /// # use std::time::Duration;
58
64
/// # futures::executor::block_on(async {
59
- /// let client = RawClient::new(vec!["192.168.0.100"]).await.unwrap();
65
+ /// let client = RawClient::new_with_config(
66
+ /// vec!["192.168.0.100"],
67
+ /// Config::default().with_timeout(Duration::from_secs(60)),
68
+ /// ).await.unwrap();
60
69
/// # });
61
70
/// ```
62
71
pub async fn new_with_config < S : Into < String > > (
@@ -72,22 +81,27 @@ impl Client {
72
81
} )
73
82
}
74
83
75
- /// Set the column family of requests.
76
- ///
77
- /// This function returns a new `Client`, requests created with it will have the
78
- /// supplied column family constraint. The original `Client` can still be used.
84
+ /// Create a new client which is a clone of `self`, but which uses an explicit column family for
85
+ /// all requests.
79
86
///
80
- /// By default, raw client uses the `Default` column family.
87
+ /// This function returns a new `Client`; requests created with the new client will use the
88
+ /// supplied column family. The original `Client` can still be used (without the new
89
+ /// column family).
81
90
///
82
- /// For normal users of the raw API, you don't need to use other column families .
91
+ /// By default, raw clients use the `Default` column family .
83
92
///
84
93
/// # Examples
94
+ ///
85
95
/// ```rust,no_run
86
96
/// # use tikv_client::{Config, RawClient, ColumnFamily};
87
97
/// # use futures::prelude::*;
88
98
/// # use std::convert::TryInto;
89
99
/// # futures::executor::block_on(async {
90
- /// let client = RawClient::new(vec!["192.168.0.100"]).await.unwrap().with_cf(ColumnFamily::Write);
100
+ /// let client = RawClient::new(vec!["192.168.0.100"])
101
+ /// .await
102
+ /// .unwrap()
103
+ /// .with_cf(ColumnFamily::Write);
104
+ /// // Fetch a value at "foo" from the Write CF.
91
105
/// let get_request = client.get("foo".to_owned());
92
106
/// # });
93
107
/// ```
@@ -411,11 +425,11 @@ impl Client {
411
425
///
412
426
/// Once resolved this request will result in a set of scanners over the given keys.
413
427
///
414
- /// **Warning**: This method is experimental. The `each_limit` parameter does not work as expected.
415
- /// It does not limit the number of results returned of each range,
428
+ /// **Warning**: This method is experimental.
429
+ /// The `each_limit` parameter does not limit the number of results returned of each range,
416
430
/// instead it limits the number of results in each region of each range.
417
- /// As a result, you may get **more than** `each_limit` key-value pairs for each range.
418
- /// But you should not miss any entries.
431
+ /// As a result, you may get **more than** `each_limit` key-value pairs for each range,
432
+ /// but you should not miss any entries.
419
433
///
420
434
/// # Examples
421
435
/// ```rust,no_run
0 commit comments