Struct bb8_tivk::RawClient [−][src]
pub struct RawClient { /* fields omitted */ }
Expand description
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 request methods are Future
s that must be
awaited to execute.
Implementations
impl Client
[src]
impl Client
[src]pub async fn new<S>(pd_endpoints: Vec<S, Global>) -> Result<Client, Error> where
S: Into<String>,
[src]
pub async fn new<S>(pd_endpoints: Vec<S, Global>) -> Result<Client, Error> where
S: Into<String>,
[src]Create a raw Client
and connect to the TiKV cluster.
Because TiKV is managed by a PD cluster, the endpoints for PD must be provided, not the TiKV nodes. It’s important to include more than one PD endpoint (include all endpoints, 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>(
pd_endpoints: Vec<S, Global>,
config: Config
) -> Result<Client, Error> where
S: Into<String>,
[src]
pub async fn new_with_config<S>(
pd_endpoints: Vec<S, Global>,
config: Config
) -> Result<Client, Error> where
S: Into<String>,
[src]Create a raw Client
with a custom configuration, and connect to the TiKV cluster.
Because TiKV is managed by a PD cluster, the endpoints for PD must be provided, not the TiKV nodes. It’s important to include more than one PD endpoint (include all endpoints, if possible), this helps avoid having a single point of failure.
Examples
let client = RawClient::new_with_config( vec!["192.168.0.100"], Config::default().with_timeout(Duration::from_secs(60)), ).await.unwrap();
pub fn with_cf(&self, cf: ColumnFamily) -> Client
[src]
pub fn with_cf(&self, cf: ColumnFamily) -> Client
[src]Create a new client which is a clone of self
, but which uses an explicit column family for
all requests.
This function returns a new Client
; requests created with the new client will use the
supplied column family. The original Client
can still be used (without the new
column family).
By default, raw clients use the Default
column family.
Examples
let client = RawClient::new(vec!["192.168.0.100"]) .await .unwrap() .with_cf(ColumnFamily::Write); // Fetch a value at "foo" from the Write CF. let get_request = client.get("foo".to_owned());
pub fn with_atomic_for_cas(&self) -> Client
[src]
pub fn with_atomic_for_cas(&self) -> Client
[src]Set to use the atomic mode.
The only reason of using atomic mode is the
compare_and_swap
operation. To guarantee
the atomicity of CAS, write operations like put
or
delete
in atomic mode are more expensive. Some
operations are not supported in the mode.
pub async fn get(
&'_ self,
key: impl Into<Key>
) -> Result<Option<Vec<u8, Global>>, Error>
[src]
pub async fn get(
&'_ self,
key: impl Into<Key>
) -> Result<Option<Vec<u8, Global>>, Error>
[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, Global>, Error>
[src]
pub async fn batch_get(
&'_ self,
keys: impl IntoIterator<Item = impl Into<Key>>
) -> Result<Vec<KvPair, Global>, Error>
[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<Vec<u8, Global>>
) -> Result<(), Error>
[src]
pub async fn put(
&'_ self,
key: impl Into<Key>,
value: impl Into<Vec<u8, Global>>
) -> Result<(), Error>
[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<(), Error>
[src]
pub async fn batch_put(
&'_ self,
pairs: impl IntoIterator<Item = impl Into<KvPair>>
) -> Result<(), Error>
[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<(), Error>
[src]
pub async fn delete(&'_ self, key: impl Into<Key>) -> Result<(), Error>
[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<(), Error>
[src]
pub async fn batch_delete(
&'_ self,
keys: impl IntoIterator<Item = impl Into<Key>>
) -> Result<(), Error>
[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<(), Error>
[src]
pub async fn delete_range(
&'_ self,
range: impl Into<BoundRange>
) -> Result<(), Error>
[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, Global>, Error>
[src]
pub async fn scan(
&'_ self,
range: impl Into<BoundRange>,
limit: u32
) -> Result<Vec<KvPair, Global>, Error>
[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, Global>, Error>
[src]
pub async fn scan_keys(
&'_ self,
range: impl Into<BoundRange>,
limit: u32
) -> Result<Vec<Key, Global>, Error>
[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, Global>, Error>
[src]
pub async fn batch_scan(
&'_ self,
ranges: impl IntoIterator<Item = impl Into<BoundRange>>,
each_limit: u32
) -> Result<Vec<KvPair, Global>, Error>
[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, Global>, Error>
[src]
pub async fn batch_scan_keys(
&'_ self,
ranges: impl IntoIterator<Item = impl Into<BoundRange>>,
each_limit: u32
) -> Result<Vec<Key, Global>, Error>
[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 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 compare_and_swap(
&'_ self,
key: impl Into<Key>,
previous_value: impl Into<Option<Vec<u8, Global>>>,
new_value: impl Into<Vec<u8, Global>>
) -> Result<(Option<Vec<u8, Global>>, bool), Error>
[src]
pub async fn compare_and_swap(
&'_ self,
key: impl Into<Key>,
previous_value: impl Into<Option<Vec<u8, Global>>>,
new_value: impl Into<Vec<u8, Global>>
) -> Result<(Option<Vec<u8, Global>>, bool), Error>
[src]Create a new atomic ‘compare and set’ request.
Once resolved this request will result in an atomic `compare and set’ operation for the given key.
If the value retrived is equal to current_value
, new_value
is
written.
Return Value
A tuple is returned if successful: the previous value and whether the value is swapped
Trait Implementations
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,