Struct tikv_client::RawClient[][src]

pub struct RawClient {
    rpc: Arc<PdRpcClient>,
    cf: Option<ColumnFamily>,
}

The TiKV raw Client is used to interact with TiKV using raw requests.

Raw requests don’t need a wrapping transaction. Each request is immediately processed once executed.

The returned results of raw requests are Futures that must be awaited to execute.

Fields

rpc: Arc<PdRpcClient>cf: Option<ColumnFamily>

Implementations

impl Client[src]

pub async fn new<S: Into<String>>(pd_endpoints: Vec<S>) -> Result<Client>[src]

Create a raw Client.

It’s important to include more than one PD endpoint (include all, if possible!) This helps avoid having a single point of failure.

Examples

let client = RawClient::new(vec!["192.168.0.100"]).await.unwrap();

pub async fn new_with_config<S: Into<String>>(
    pd_endpoints: Vec<S>,
    config: Config
) -> Result<Client>
[src]

Create a raw Client.

It’s important to include more than one PD endpoint (include all, if possible!) This helps avoid having a single point of failure.

Examples

let client = RawClient::new(vec!["192.168.0.100"]).await.unwrap();

pub fn with_cf(&self, cf: ColumnFamily) -> Client[src]

Set the column family of requests.

This function returns a new Client, requests created with it will have the supplied column family constraint. The original Client can still be used.

By default, raw client uses the Default column family.

For normal users of the raw API, you don’t need to use other column families.

Examples

let client = RawClient::new(vec!["192.168.0.100"]).await.unwrap().with_cf(ColumnFamily::Write);
let get_request = client.get("foo".to_owned());

pub async fn get(&self, key: impl Into<Key>) -> Result<Option<Value>>[src]

Create a new ‘get’ request.

Once resolved this request will result in the fetching of the value associated with the given key.

Retuning Ok(None) indicates the key does not exist in TiKV.

Examples

let key = "TiKV".to_owned();
let req = client.get(key);
let result: Option<Value> = req.await.unwrap();

pub async fn batch_get(
    &self,
    keys: impl IntoIterator<Item = impl Into<Key>>
) -> Result<Vec<KvPair>>
[src]

Create a new ‘batch get’ request.

Once resolved this request will result in the fetching of the values associated with the given keys.

Non-existent entries will not appear in the result. The order of the keys is not retained in the result.

Examples

let keys = vec!["TiKV".to_owned(), "TiDB".to_owned()];
let req = client.batch_get(keys);
let result: Vec<KvPair> = req.await.unwrap();

pub async fn put(
    &self,
    key: impl Into<Key>,
    value: impl Into<Value>
) -> Result<()>
[src]

Create a new ‘put’ request.

Once resolved this request will result in the setting of the value associated with the given key.

Examples

let key = "TiKV".to_owned();
let val = "TiKV".to_owned();
let req = client.put(key, val);
let result: () = req.await.unwrap();

pub async fn batch_put(
    &self,
    pairs: impl IntoIterator<Item = impl Into<KvPair>>
) -> Result<()>
[src]

Create a new ‘batch put’ request.

Once resolved this request will result in the setting of the values associated with the given keys.

Examples

let kvpair1 = ("PD".to_owned(), "Go".to_owned());
let kvpair2 = ("TiKV".to_owned(), "Rust".to_owned());
let iterable = vec![kvpair1, kvpair2];
let req = client.batch_put(iterable);
let result: () = req.await.unwrap();

pub async fn delete(&self, key: impl Into<Key>) -> Result<()>[src]

Create a new ‘delete’ request.

Once resolved this request will result in the deletion of the given key.

It does not return an error if the key does not exist in TiKV.

Examples

let key = "TiKV".to_owned();
let req = client.delete(key);
let result: () = req.await.unwrap();

pub async fn batch_delete(
    &self,
    keys: impl IntoIterator<Item = impl Into<Key>>
) -> Result<()>
[src]

Create a new ‘batch delete’ request.

Once resolved this request will result in the deletion of the given keys.

It does not return an error if some of the keys do not exist and will delete the others.

Examples

let keys = vec!["TiKV".to_owned(), "TiDB".to_owned()];
let req = client.batch_delete(keys);
let result: () = req.await.unwrap();

pub async fn delete_range(&self, range: impl Into<BoundRange>) -> Result<()>[src]

Create a new ‘delete range’ request.

Once resolved this request will result in the deletion of all keys lying in the given range.

Examples

let inclusive_range = "TiKV"..="TiDB";
let req = client.delete_range(inclusive_range.into_owned());
let result: () = req.await.unwrap();

pub async fn scan(
    &self,
    range: impl Into<BoundRange>,
    limit: u32
) -> Result<Vec<KvPair>>
[src]

Create a new ‘scan’ request.

Once resolved this request will result in a Vec of key-value pairs that lies in the specified range.

If the number of eligible key-value pairs are greater than limit, only the first limit pairs are returned, ordered by the key.

Examples

let inclusive_range = "TiKV"..="TiDB";
let req = client.scan(inclusive_range.into_owned(), 2);
let result: Vec<KvPair> = req.await.unwrap();

pub async fn scan_keys(
    &self,
    range: impl Into<BoundRange>,
    limit: u32
) -> Result<Vec<Key>>
[src]

Create a new ‘scan’ request that only returns the keys.

Once resolved this request will result in a Vec of keys that lies in the specified range.

If the number of eligible keys are greater than limit, only the first limit pairs are returned, ordered by the key.

Examples

let inclusive_range = "TiKV"..="TiDB";
let req = client.scan_keys(inclusive_range.into_owned(), 2);
let result: Vec<Key> = req.await.unwrap();

pub async fn batch_scan(
    &self,
    ranges: impl IntoIterator<Item = impl Into<BoundRange>>,
    each_limit: u32
) -> Result<Vec<KvPair>>
[src]

Create a new ‘batch scan’ request.

Once resolved this request will result in a set of scanners over the given keys.

Warning: This method is experimental. The each_limit parameter does not work as expected. It does not limit the number of results returned of each range, instead it limits the number of results in each region of each range. As a result, you may get more than each_limit key-value pairs for each range. But you should not miss any entries.

Examples

let inclusive_range1 = "TiDB"..="TiKV";
let inclusive_range2 = "TiKV"..="TiSpark";
let iterable = vec![inclusive_range1.into_owned(), inclusive_range2.into_owned()];
let req = client.batch_scan(iterable, 2);
let result = req.await;

pub async fn batch_scan_keys(
    &self,
    ranges: impl IntoIterator<Item = impl Into<BoundRange>>,
    each_limit: u32
) -> Result<Vec<Key>>
[src]

Create a new ‘batch scan’ request that only returns the keys.

Once resolved this request will result in a set of scanners over the given keys.

Warning: This method is experimental. The each_limit parameter does not work as expected. It does not limit the number of results returned of each range, instead it limits the number of results in each region of each range. As a result, you may get more than each_limit key-value pairs for each range. But you should not miss any entries.

Examples

let inclusive_range1 = "TiDB"..="TiKV";
let inclusive_range2 = "TiKV"..="TiSpark";
let iterable = vec![inclusive_range1.into_owned(), inclusive_range2.into_owned()];
let req = client.batch_scan(iterable, 2);
let result = req.await;

async fn scan_inner(
    &self,
    range: impl Into<BoundRange>,
    limit: u32,
    key_only: bool
) -> Result<Vec<KvPair>>
[src]

async fn batch_scan_inner(
    &self,
    ranges: impl IntoIterator<Item = impl Into<BoundRange>>,
    each_limit: u32,
    key_only: bool
) -> Result<Vec<KvPair>>
[src]

Trait Implementations

impl Clone for Client[src]

Auto Trait Implementations

impl !RefUnwindSafe for Client

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]