Skip to content

Commit f0370d3

Browse files
committed
Merge branch 'master' into scan-range-fix
Signed-off-by: Ana Hobden <operator@hoverbear.org>
2 parents f1b4d3f + 8729350 commit f0370d3

26 files changed

+615
-853
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ fxhash = "0.2"
2424
grpcio = { version = "0.5.0-alpha", features = [ "secure", "prost-codec" ], default-features = false }
2525
lazy_static = "0.2.1"
2626
log = "0.3.9"
27-
protobuf = "2"
2827
serde = "1.0"
2928
serde_derive = "1.0"
3029
tokio-core = "0.1"
3130
tokio-timer = "0.2"
3231

3332
[dependencies.kvproto]
3433
git = "https://github.com/pingcap/kvproto.git"
35-
branch = "raft-0.5.0"
3634

3735
[dependencies.prometheus]
3836
version = "0.4.2"

examples/common/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
2+
13
use clap::{crate_version, App, Arg};
24
use std::path::PathBuf;
35

examples/raw.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
// Copyright 2018 The TiKV Project Authors
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
132

143
mod common;
154

examples/transaction.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
// Copyright 2018 The TiKV Project Authors
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
132

143
mod common;
154

src/config.rs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
2+
3+
use serde_derive::{Deserialize, Serialize};
4+
use std::{path::PathBuf, time::Duration};
5+
6+
/// The configuration for either a [`raw::Client`](raw/struct.Client.html) or a
7+
/// [`transaction::Client`](transaction/struct.Client.html).
8+
///
9+
/// Because TiKV is managed by a [PD](https://github.com/pingcap/pd/) cluster, the endpoints for PD
10+
/// must be provided, **not** the TiKV nodes.
11+
///
12+
/// It's important to **include more than one PD endpoint** (include all, if possible!)
13+
/// This helps avoid having a *single point of failure*.
14+
///
15+
/// By default, this client will use an insecure connection over instead of one protected by
16+
/// Transport Layer Security (TLS). Your deployment may have chosen to rely on security measures
17+
/// such as a private network, or a VPN layer to provid secure transmission.
18+
///
19+
/// To use a TLS secured connection, use the `with_security` function to set the required
20+
/// parameters.
21+
///
22+
/// TiKV does not currently offer encrypted storage (or encryption-at-rest).
23+
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
24+
#[serde(default)]
25+
#[serde(rename_all = "kebab-case")]
26+
pub struct Config {
27+
pub(crate) pd_endpoints: Vec<String>,
28+
pub(crate) ca_path: Option<PathBuf>,
29+
pub(crate) cert_path: Option<PathBuf>,
30+
pub(crate) key_path: Option<PathBuf>,
31+
pub(crate) timeout: Duration,
32+
}
33+
34+
const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
35+
36+
impl Config {
37+
/// Create a new [`Config`](struct.Config.html) which coordinates with the given PD endpoints.
38+
///
39+
/// It's important to **include more than one PD endpoint** (include all, if possible!)
40+
/// This helps avoid having a *single point of failure*.
41+
///
42+
/// ```rust
43+
/// # use tikv_client::Config;
44+
/// let config = Config::new(vec!["192.168.0.100:2379", "192.168.0.101:2379"]);
45+
/// ```
46+
pub fn new(pd_endpoints: impl IntoIterator<Item = impl Into<String>>) -> Self {
47+
Config {
48+
pd_endpoints: pd_endpoints.into_iter().map(Into::into).collect(),
49+
ca_path: None,
50+
cert_path: None,
51+
key_path: None,
52+
timeout: DEFAULT_REQUEST_TIMEOUT,
53+
}
54+
}
55+
56+
/// Set the certificate authority, certificate, and key locations for the
57+
/// [`Config`](struct.Config.html).
58+
///
59+
/// By default, TiKV connections do not utilize transport layer security. Enable it by setting
60+
/// these values.
61+
///
62+
/// ```rust
63+
/// # use tikv_client::Config;
64+
/// let config = Config::new(vec!["192.168.0.100:2379", "192.168.0.101:2379"])
65+
/// .with_security("root.ca", "internal.cert", "internal.key");
66+
/// ```
67+
pub fn with_security(
68+
mut self,
69+
ca_path: impl Into<PathBuf>,
70+
cert_path: impl Into<PathBuf>,
71+
key_path: impl Into<PathBuf>,
72+
) -> Self {
73+
self.ca_path = Some(ca_path.into());
74+
self.cert_path = Some(cert_path.into());
75+
self.key_path = Some(key_path.into());
76+
self
77+
}
78+
79+
pub fn timeout(mut self, timeout: Duration) -> Self {
80+
self.timeout = timeout;
81+
self
82+
}
83+
}

src/errors.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
// Copyright 2018 The TiKV Project Authors
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// See the License for the specific language governing permissions and
12-
// limitations under the License.
1+
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
2+
133
use failure::{Backtrace, Context, Fail};
144
use grpcio;
155
use std::fmt::{self, Display};

0 commit comments

Comments
 (0)