pub struct ConfiguredReadRequestBuilder { /* private fields */ }Expand description
A fully configured read request that is ready to be built.
Implementations§
Source§impl ConfiguredReadRequestBuilder
impl ConfiguredReadRequestBuilder
Sourcepub fn set_limit(self, limit: i64) -> Self
pub fn set_limit(self, limit: i64) -> Self
Sets an optional limit on how many rows could be retrieved.
§Example
let request = ReadRequest::builder("Users", vec!["Id"])
.with_keys(KeySet::all())
.set_limit(10)
.build();If fewer rows are found, only the matching rows will be returned.
Sourcepub fn set_request_tag(self, tag: impl Into<String>) -> Self
pub fn set_request_tag(self, tag: impl Into<String>) -> Self
Sets the request tag to use for this read.
§Example
let request = ReadRequest::builder("Users", vec!["Id"])
.with_keys(KeySet::all())
.set_request_tag("my-tag")
.build();See also: Troubleshooting with tags
Sourcepub fn set_priority(self, priority: Priority) -> Self
pub fn set_priority(self, priority: Priority) -> Self
Sets the RPC priority to use for this read request.
§Example
let request = ReadRequest::builder("Users", vec!["Id"])
.with_keys(KeySet::all())
.set_priority(Priority::Low)
.build();Sourcepub fn set_directed_read_options(self, options: DirectedReadOptions) -> Self
pub fn set_directed_read_options(self, options: DirectedReadOptions) -> Self
Sets the directed read options for this request.
let dro = DirectedReadOptions::default();
let req = ReadRequest::builder("MyTable", vec!["col1"])
.with_keys(KeySet::all())
.set_directed_read_options(dro)
.build();DirectedReadOptions can only be specified for a read-only transaction, otherwise Spanner returns an INVALID_ARGUMENT error.
Sourcepub fn set_order_by(self, order_by: OrderBy) -> Self
pub fn set_order_by(self, order_by: OrderBy) -> Self
Sets the order in which rows are returned.
§Example
let request = ReadRequest::builder("Users", vec!["Id"])
.with_keys(KeySet::all())
.set_order_by(OrderBy::NoOrder);By default, Spanner returns result rows in primary key order (or index key
order if reading via an index) except for PartitionRead requests.
For applications that don’t require rows to be returned in primary key
(ORDER_BY_PRIMARY_KEY) order, setting ORDER_BY_NO_ORDER option allows
Spanner to optimize row retrieval, resulting in lower latencies in certain
cases (for example, bulk point lookups).
Sourcepub fn set_lock_hint(self, lock_hint: LockHint) -> Self
pub fn set_lock_hint(self, lock_hint: LockHint) -> Self
Sets the lock hint for this read.
§Example
let request = ReadRequest::builder("Users", vec!["Id"])
.with_keys(KeySet::all())
.set_lock_hint(LockHint::Exclusive);Lock hints can only be used with read-write transactions.
By default, Spanner acquires shared read locks, which allows other reads to still access the data until your transaction is ready to commit.
Requesting exclusive locks (LOCK_HINT_EXCLUSIVE) is beneficial if you observe
high write contention. It prevents deadlocks by avoiding the situation where
multiple transactions initially acquire shared locks and then both try to upgrade
to exclusive locks at the same time.
Request exclusive locks judiciously because they block others from reading that data for the entire transaction, rather than just when the writes are being performed.
Sourcepub fn with_attempt_timeout(self, timeout: Duration) -> Self
pub fn with_attempt_timeout(self, timeout: Duration) -> Self
Sets the per-attempt timeout for this read request.
Sourcepub fn with_retry_policy(self, policy: impl Into<RetryPolicyArg>) -> Self
pub fn with_retry_policy(self, policy: impl Into<RetryPolicyArg>) -> Self
Sets the retry policy for this read request.
Sourcepub fn with_backoff_policy(self, policy: impl Into<BackoffPolicyArg>) -> Self
pub fn with_backoff_policy(self, policy: impl Into<BackoffPolicyArg>) -> Self
Sets the backoff policy for this read request.
Sourcepub fn build(self) -> ReadRequest
pub fn build(self) -> ReadRequest
Builds the configured ReadRequest.
Trait Implementations§
Source§impl Clone for ConfiguredReadRequestBuilder
impl Clone for ConfiguredReadRequestBuilder
Source§fn clone(&self) -> ConfiguredReadRequestBuilder
fn clone(&self) -> ConfiguredReadRequestBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ConfiguredReadRequestBuilder
impl !UnwindSafe for ConfiguredReadRequestBuilder
impl Freeze for ConfiguredReadRequestBuilder
impl Send for ConfiguredReadRequestBuilder
impl Sync for ConfiguredReadRequestBuilder
impl Unpin for ConfiguredReadRequestBuilder
impl UnsafeUnpin for ConfiguredReadRequestBuilder
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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