Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() -> Result<()> {

// When we first create a client we receive a `Connect` structure which must be resolved before
// the client is actually connected and usable.
let unconnnected_client = Client::new(&config);
let unconnnected_client = Client::new(config);
let client = unconnnected_client.wait()?;

// Requests are created from the connected client. These calls return structures which
Expand Down
2 changes: 1 addition & 1 deletion examples/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn main() {
Config::new(args.pd)
};

let txn = Client::new(&config)
let txn = Client::new(config)
.wait()
.expect("Could not connect to tikv");

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
//! ]).with_security("root.ca", "internal.cert", "internal.key");
//!
//! // Get an unresolved connection.
//! let connect = Client::new(&config);
//! let connect = Client::new(config);
//!
//! // Resolve the connection into a client.
//! let client = connect.wait();
Expand Down
26 changes: 13 additions & 13 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ impl Client {
/// ```rust,no_run
/// use tikv_client::{Config, raw::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait();
/// ```
#[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))]
pub fn new(config: &Config) -> Connect {
Connect::new(config.clone())
pub fn new(config: Config) -> Connect {
Connect::new(config)
}

#[inline]
Expand All @@ -62,7 +62,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Value, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let key = "TiKV";
/// let req = connected_client.get(key);
Expand All @@ -80,7 +80,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{KvPair, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let keys = vec!["TiKV", "TiDB"];
/// let req = connected_client.batch_get(keys);
Expand All @@ -100,7 +100,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Key, Value, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let key = "TiKV";
/// let val = "TiKV";
Expand All @@ -118,7 +118,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Error, Result, KvPair, Key, Value, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let kvpair1 = ("PD", "Go");
/// let kvpair2 = ("TiKV", "Rust");
Expand All @@ -140,7 +140,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Key, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let key = "TiKV";
/// let req = connected_client.delete(key);
Expand All @@ -157,7 +157,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let keys = vec!["TiKV", "TiDB"];
/// let req = connected_client.batch_delete(keys);
Expand All @@ -177,7 +177,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{KvPair, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let inclusive_range = "TiKV"..="TiDB";
/// let req = connected_client.scan(inclusive_range, 2);
Expand All @@ -194,7 +194,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Key, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let inclusive_range1 = "TiDB"..="TiKV";
/// let inclusive_range2 = "TiKV"..="TiSpark";
Expand Down Expand Up @@ -223,7 +223,7 @@ impl Client {
/// ```rust,no_run
/// # use tikv_client::{Key, Config, raw::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let inclusive_range = "TiKV"..="TiDB";
/// let req = connected_client.delete_range(inclusive_range);
Expand All @@ -242,7 +242,7 @@ impl Client {
/// use tikv_client::{Config, raw::{Client, Connect}};
/// use futures::Future;
///
/// let connect: Connect = Client::new(&Config::default());
/// let connect: Connect = Client::new(Config::default());
/// let client: Client = connect.wait().unwrap();
/// ```
pub struct Connect {
Expand Down
38 changes: 19 additions & 19 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ impl Client {
/// ```rust,no_run
/// use tikv_client::{Config, transaction::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait();
/// ```
#[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))]
pub fn new(config: &Config) -> Connect {
Connect::new(config.clone())
pub fn new(config: Config) -> Connect {
Connect::new(config)
}

/// Create a new [`Transaction`](struct.Transaction.html) using the timestamp from [`current_timestamp`](struct.Client.html#method.current_timestamp).
Expand All @@ -48,7 +48,7 @@ impl Client {
/// ```rust,no_run
/// use tikv_client::{Config, transaction::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait().unwrap();
/// let transaction = client.begin();
/// // ... Issue some commands.
Expand All @@ -64,7 +64,7 @@ impl Client {
/// ```rust,no_run
/// use tikv_client::{Config, transaction::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait().unwrap();
/// let timestamp = client.current_timestamp();
/// let transaction = client.begin_with_timestamp(timestamp);
Expand All @@ -81,7 +81,7 @@ impl Client {
/// ```rust,no_run
/// use tikv_client::{Config, transaction::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait().unwrap();
/// let snapshot = client.snapshot();
/// // ... Issue some commands.
Expand All @@ -95,7 +95,7 @@ impl Client {
/// ```rust,no_run
/// use tikv_client::{Config, transaction::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait().unwrap();
/// let timestamp = client.current_timestamp();
/// ```
Expand All @@ -112,7 +112,7 @@ impl Client {
/// use tikv_client::{Config, transaction::{Client, Connect}};
/// use futures::Future;
///
/// let connect: Connect = Client::new(&Config::default());
/// let connect: Connect = Client::new(Config::default());
/// let client: Client = connect.wait().unwrap();
/// ```
pub struct Connect {
Expand Down Expand Up @@ -187,7 +187,7 @@ impl Transaction {
/// ```rust,no_run
/// use tikv_client::{Config, transaction::Client};
/// use futures::Future;
/// let connect = Client::new(&Config::default());
/// let connect = Client::new(Config::default());
/// let client = connect.wait().unwrap();
/// let txn = client.begin();
/// ```
Expand All @@ -202,7 +202,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Config, transaction::Client};
/// # use futures::Future;
/// # let connect = Client::new(&Config::default());
/// # let connect = Client::new(Config::default());
/// # let connected_client = connect.wait().unwrap();
/// let txn = connected_client.begin();
/// // ... Do some actions.
Expand All @@ -218,7 +218,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Config, transaction::Client};
/// # use futures::Future;
/// # let connect = Client::new(&Config::default());
/// # let connect = Client::new(Config::default());
/// # let connected_client = connect.wait().unwrap();
/// let txn = connected_client.begin();
/// // ... Do some actions.
Expand All @@ -234,7 +234,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Config, transaction::Client};
/// # use futures::Future;
/// # let connect = Client::new(&Config::default());
/// # let connect = Client::new(Config::default());
/// # let connected_client = connect.wait().unwrap();
/// let mut txn = connected_client.begin();
/// // ... Do some actions.
Expand All @@ -254,7 +254,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Config, transaction::{Client, Timestamp}};
/// # use futures::Future;
/// # let connect = Client::new(&Config::default());
/// # let connect = Client::new(Config::default());
/// # let connected_client = connect.wait().unwrap();
/// let txn = connected_client.begin();
/// // ... Do some actions.
Expand All @@ -269,7 +269,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Config, transaction::{Client, Snapshot}};
/// # use futures::Future;
/// # let connect = Client::new(&Config::default());
/// # let connect = Client::new(Config::default());
/// # let connected_client = connect.wait().unwrap();
/// let txn = connected_client.begin();
/// // ... Do some actions.
Expand All @@ -284,7 +284,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Config, transaction::{Client, IsolationLevel}};
/// # use futures::Future;
/// # let connect = Client::new(&Config::default());
/// # let connect = Client::new(Config::default());
/// # let connected_client = connect.wait().unwrap();
/// let mut txn = connected_client.begin();
/// txn.set_isolation_level(IsolationLevel::SnapshotIsolation);
Expand All @@ -301,7 +301,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Value, Config, transaction::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let mut txn = connected_client.begin();
/// let key = "TiKV";
Expand All @@ -322,7 +322,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{KvPair, Config, transaction::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let mut txn = connected_client.begin();
/// let keys = vec!["TiKV", "TiDB"];
Expand Down Expand Up @@ -350,7 +350,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Key, Value, Config, transaction::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let mut txn = connected_client.begin();
/// let key = "TiKV";
Expand All @@ -371,7 +371,7 @@ impl Transaction {
/// ```rust,no_run
/// # use tikv_client::{Key, Config, transaction::Client};
/// # use futures::Future;
/// # let connecting_client = Client::new(&Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connecting_client = Client::new(Config::new(vec!["192.168.0.100", "192.168.0.101"]));
/// # let connected_client = connecting_client.wait().unwrap();
/// let mut txn = connected_client.begin();
/// let key = "TiKV";
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn wipe_all(client: &Client) {
}

fn connect() -> Client {
let client = Client::new(&Config::new(pd_addr()))
let client = Client::new(Config::new(pd_addr()))
.wait()
.expect("Could not connect to tikv");
wipe_all(&client);
Expand Down