|
13 | 13 | #![recursion_limit = "128"]
|
14 | 14 | #![type_length_limit = "1572864"]
|
15 | 15 |
|
| 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 Rust bindings to [TiKV](https://github.com/tikv/tikv), a distributed |
| 23 | +//! 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, depend on it 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 give a `cargo build --package tikv-client` 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 `pd` |
| 56 | +//! 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-View |
| 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. |
| 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 | +
|
16 | 112 | use futures::Future;
|
17 | 113 | use serde_derive::*;
|
18 | 114 | use std::{
|
|
0 commit comments