Skip to content

Commit a5a6b15

Browse files
authored
Add README and some lib.rs docs (#31)
* Add README and some lib.rs docs Signed-off-by: Ana Hobden <operator@hoverbear.org> * Apply suggestions from code review Nit fixes. Signed-off-by: Ana Hobden <operator@hoverbear.org> * Nit fixes Signed-off-by: Ana Hobden <operator@hoverbear.org>
1 parent c74a01a commit a5a6b15

File tree

4 files changed

+153
-17
lines changed

4 files changed

+153
-17
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# TiKV Client (Rust)
2+
3+
[![Build Status](https://travis-ci.org/tikv/client-rust.svg?branch=master)](https://travis-ci.org/pingcap/client-rust)
4+
[![Documentation](https://docs.rs/tikv-client/badge.svg)](https://docs.rs/tikv-client/)
5+
6+
> Currently this crate is experimental and some portions (e.g. the Transactional API) are still in active development. You're encouraged to use this library for testing and to help us find problems!
7+
8+
This crate provides a clean, ready to use client for [TiKV](https://github.com/tikv/tikv), a
9+
distributed transactional Key-Value database written in Rust.
10+
11+
With this crate you can easily connect to any TiKV deployment, interact with it, and mutate the data it contains.
12+
13+
This is an open source (Apache 2) project hosted by the Cloud Native Computing Foundation (CNCF) and maintained by the TiKV Authors. *We'd love it if you joined us in improving this project.*
14+
15+
## Install
16+
17+
There are no special requirements to use this. It is a Rust 2018 edition crate supporting stable and nightly.
18+
19+
To use this crate in your project, add it as a dependency in the `Cargo.toml` of your Rust project:
20+
21+
```toml
22+
[dependencies]
23+
# ...Your other dependencies...
24+
tikv-client = "~0.1"
25+
```
26+
27+
## Access the documentation
28+
29+
We recommend using the cargo-generated documentation to browse and understand the API. We've done
30+
our best to include ample, tested, and understandable examples.
31+
32+
You can visit [docs.rs/tikv-client](https://docs.rs/tikv-client/), or build the documentation yourself.
33+
34+
You can access the documentation on your machine by running the following in any project that depends on `tikv-client`.
35+
36+
```bash
37+
cargo doc --package tikv-client --open
38+
# If it didn't work, browse file URL it tried to open with your browser.
39+
```

src/lib.rs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,102 @@
1313
#![recursion_limit = "128"]
1414
#![type_length_limit = "1572864"]
1515

16+
//! TiKV Client for Rust.
17+
//!
18+
//! > Currently this crate is experimental and some portions (eg the Transactional API) are still
19+
//! > in active development. You're encouraged to use this library for testing and help us find
20+
//! > problems!
21+
//!
22+
//! This crate provides a clean, ready to use client for [TiKV](https://github.com/tikv/tikv), a
23+
//! distributed transactional Key-Value database written in Rust.
24+
//!
25+
//! With this crate you can easily connect to any TiKV deployment, interact with it, and mutate the
26+
//! data it contains.
27+
//!
28+
//! This is an open source (Apache 2) project hosted by the Cloud Native Computing Foundation
29+
//! (CNCF) and maintained by the TiKV Authors. *We'd love it if you joined us in improving this
30+
//! project.*
31+
//!
32+
//! ## Install
33+
//!
34+
//! There are no special requirements to use this. It is a Rust 2018 edition crate supporting
35+
//! stable and nightly.
36+
//!
37+
//! To use this crate in your project, add it as a dependency in the `Cargo.toml` of your Rust project:
38+
//!
39+
//! ```toml
40+
//! [dependencies]
41+
//! # ...Your other dependencies...
42+
//! tikv-client = "~0.1"
43+
//! futures = "0.1" # You'll need this later.
44+
//! ```
45+
//!
46+
//! Then run a `cargo build --package tikv-client` command to test building the crate.
47+
//!
48+
//! Next, you need to choose the API appropriate for your needs.
49+
//!
50+
//! ## Choosing an API
51+
//!
52+
//! This crate offers both [**raw**](raw/index.html) and
53+
//! [**transactional**](transaction/index.html) APIs. You should choose just one for your system.
54+
//!
55+
//! The *consequence* of supporting transactions is increased overhead of coordination with the
56+
//! placement driver for timestamp acquisition. This is approximately 1 RTT.
57+
//!
58+
//! *While it is possible to use both APIs at the same time, doing so is unsafe and unsupported.*
59+
//!
60+
//! Choose the one that suites your needs as described below, then add the import statement to your
61+
//! file where you need to use the library.
62+
//!
63+
//! ### Transactional
64+
//!
65+
//! The [transactional](transaction/index.html) API supports **transactions** via Multi-Version
66+
//! Concurrency Control (MVCC).
67+
//!
68+
//! **Best when you mostly do** complex sets of actions, actions which may require a rollback,
69+
//! operations affecting multiple keys or values, or operations that depend on strong ordering.
70+
//!
71+
//! ```rust
72+
//! use tikv_client::{*, transaction::*};
73+
//! ```
74+
//!
75+
//! ### Raw
76+
//!
77+
//! The [raw](raw/index.html) API has **reduced coordination overhead**, but lacks any
78+
//! transactional abilities.
79+
//!
80+
//! **Best when you mostly do** single row changes, and have very limited cross-row (eg. foreign
81+
//! key) requirements. You will not be able to use transactions with this API.
82+
//!
83+
//! ```rust
84+
//! use tikv_client::{*, raw::*};
85+
//! ```
86+
//!
87+
//! ## Connect
88+
//!
89+
//! Regardless of which API you choose, you'll need to connect your client
90+
//! ([raw](raw/struct.Client.html), [transactional](transaction/struct.Client.html)).
91+
//!
92+
//! ```rust
93+
//! # use tikv_client::{*, raw::*};
94+
//! use futures::Future;
95+
//!
96+
//! // Configure endpoints and optional TLS.
97+
//! let config = Config::new(vec![ // A list of PD endpoints.
98+
//! "192.168.0.100:2379",
99+
//! "192.168.0.101:2379",
100+
//! ]).with_security("root.ca", "internal.cert", "internal.key");
101+
//!
102+
//! // Get an unresolved connection.
103+
//! let connect = Client::new(&config);
104+
//!
105+
//! // Resolve the connection into a client.
106+
//! let client = connect.wait();
107+
//! ```
108+
//!
109+
//! At this point, you should seek the documentation in the related API modules.
110+
//!
111+
16112
use futures::Future;
17113
use serde_derive::*;
18114
use std::{

src/raw.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
/// Raw related functionality.
15-
///
16-
/// Using the [`raw::Client`](struct.Client.html) you can utilize TiKV's raw interface.
17-
///
18-
/// This interface offers optimal performance as it does not require coordination with a timestamp
19-
/// oracle, while the transactional interface does.
20-
///
21-
/// **Warning:** It is not advisible to use the both raw and transactional functionality in the same keyspace.
22-
///
14+
//! Raw related functionality.
15+
//!
16+
//! Using the [`raw::Client`](struct.Client.html) you can utilize TiKV's raw interface.
17+
//!
18+
//! This interface offers optimal performance as it does not require coordination with a timestamp
19+
//! oracle, while the transactional interface does.
20+
//!
21+
//! **Warning:** It is not advisable to use both raw and transactional functionality in the same keyspace.
22+
//!
2323
use crate::{rpc::RpcClient, Config, Error, Key, KeyRange, KvFuture, KvPair, Result, Value};
2424
use futures::{future, Async, Future, Poll};
2525
use std::{
@@ -318,7 +318,7 @@ impl Deref for ColumnFamily {
318318
}
319319
}
320320

321-
pub trait RequestInner: Sized {
321+
trait RequestInner: Sized {
322322
type Resp;
323323

324324
fn execute(self, client: Arc<RpcClient>, cf: Option<ColumnFamily>) -> KvFuture<Self::Resp>;

src/transaction.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
/*! Transactional related functionality.
14+
//! Transactional related functionality.
15+
//!
16+
//! Using the [`transaction::Client`](struct.Client.html) you can utilize TiKV's transactional interface.
17+
//!
18+
//! This interface offers SQL-like transactions on top of the raw interface.
19+
//!
20+
//! **Warning:** It is not advisable to use both raw and transactional functionality in the same keyspace.
21+
//!
1522
16-
Using the [`transaction::Client`](struct.Client.html) you can utilize TiKV's transactional interface.
17-
18-
This interface offers SQL-like transactions on top of the raw interface.
19-
20-
**Warning:** It is not advisible to use the both raw and transactional functionality in the same keyspace.
21-
*/
2223
use crate::{Config, Error, Key, KvPair, Value};
2324
use futures::{Future, Poll, Stream};
2425
use std::ops::RangeBounds;

0 commit comments

Comments
 (0)