pub struct TableClient { /* private fields */ }Expand description
Client for YDB table service (SQL queries)
Table service used for work with data abd DB struct with SQL queries.
TableClient contains options for make queries. See TableClient::retry_transaction for examples.
Implementations§
Source§impl TableClient
impl TableClient
pub fn clone_with_timeouts(&self, timeouts: TimeoutSettings) -> Self
Sourcepub fn clone_with_retry_timeout(&self, timeout: Duration) -> Self
pub fn clone_with_retry_timeout(&self, timeout: Duration) -> Self
Clone the table client and set new retry timeouts
Sourcepub fn clone_with_no_retry(&self) -> Self
pub fn clone_with_no_retry(&self) -> Self
Clone the table client and deny retries
Sourcepub fn clone_with_idempotent_operations(&self, idempotent: bool) -> Self
pub fn clone_with_idempotent_operations(&self, idempotent: bool) -> Self
Clone the table client and set feature operations as idempotent (can retry in more cases)
pub fn clone_with_transaction_options(&self, opts: TransactionOptions) -> Self
Sourcepub async fn retry_execute_scan_query(
&self,
query: Query,
) -> YdbResult<StreamResult>
pub async fn retry_execute_scan_query( &self, query: Query, ) -> YdbResult<StreamResult>
Execute scan query. The method will auto-retry errors while start query execution, but no retries after server start streaming result.
Sourcepub async fn retry_execute_scheme_query<T: Into<String>>(
&self,
query: T,
) -> YdbResult<()>
pub async fn retry_execute_scheme_query<T: Into<String>>( &self, query: T, ) -> YdbResult<()>
Execute scheme query with retry policy
Sourcepub async fn retry_execute_bulk_upsert(
&self,
table_path: String,
rows: Vec<Value>,
) -> YdbResult<()>
pub async fn retry_execute_bulk_upsert( &self, table_path: String, rows: Vec<Value>, ) -> YdbResult<()>
Execute bulk upsert with retry policy
Sourcepub async fn retry_transaction<CallbackFuture, CallbackResult>(
&self,
callback: impl Fn(Box<dyn Transaction>) -> CallbackFuture,
) -> YdbResultWithCustomerErr<CallbackResult>where
CallbackFuture: Future<Output = YdbResultWithCustomerErr<CallbackResult>>,
pub async fn retry_transaction<CallbackFuture, CallbackResult>(
&self,
callback: impl Fn(Box<dyn Transaction>) -> CallbackFuture,
) -> YdbResultWithCustomerErr<CallbackResult>where
CallbackFuture: Future<Output = YdbResultWithCustomerErr<CallbackResult>>,
Retry callback in transaction
retries callback as retry policy. every call of callback will within new transaction retry will call callback next time if:
- allow by retry policy
- callback return retriable error
Example with move lambda args:
let res: Option<i32> = table_client.retry_transaction(|mut t| async move {
let value: Value = t.query(Query::new("SELECT 1 + 1 as sum")).await?
.into_only_row()?
.remove_field_by_name("sum")?;
let res: Option<i32> = value.try_into()?;
return Ok(res);
}).await?;
assert_eq!(Some(2), res);Example without move lambda args - it allow to borrow external items:
let mut attempts: AtomicUsize = AtomicUsize::new(0);
let res: Option<i32> = table_client.retry_transaction(|mut t| async {
let mut t = t; // explicit move lambda argument inside async code block for borrow checker
attempts.fetch_add(1, Ordering::Relaxed); // can borrow outer values istead of move
let value: Value = t.query(Query::new("SELECT 1 + 1 as sum")).await?
.into_only_row()?
.remove_field_by_name("sum")?;
let res: Option<i32> = value.try_into()?;
return Ok(res);
}).await?;
assert_eq!(Some(2), res);
assert_eq!(1, attempts.load(Ordering::Relaxed));pub fn with_error_on_truncate(self, error_on_truncate: bool) -> Self
pub async fn copy_table( &self, source_path: String, destination_path: String, ) -> YdbResult<()>
pub async fn copy_tables(&self, tables: Vec<CopyTableItem>) -> YdbResult<()>
Trait Implementations§
Source§impl Clone for TableClient
impl Clone for TableClient
Source§fn clone(&self) -> TableClient
fn clone(&self) -> TableClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TableClient
impl !RefUnwindSafe for TableClient
impl Send for TableClient
impl Sync for TableClient
impl Unpin for TableClient
impl !UnwindSafe for TableClient
Blanket Implementations§
Source§impl<T> Any for T
impl<T> Any for T
Source§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request