pub struct DatabaseClientBuilder { /* private fields */ }Expand description
A builder for DatabaseClient.
Implementations§
Source§impl DatabaseClientBuilder
impl DatabaseClientBuilder
Sourcepub fn with_database_role(self, role: impl Into<String>) -> Self
pub fn with_database_role(self, role: impl Into<String>) -> Self
Sets the database role for the client.
§Example
let spanner = Spanner::builder().build().await?;
let database_client = spanner
.database_client("projects/my-project/instances/my-instance/databases/my-db")
.with_database_role("my-role")
.build()
.await?;Database roles are used for Fine-Grained Access Control (FGAC). You can assign a database role to a session, and that role determines the permissions for that session. For more information, see Access with FGAC.
Sourcepub fn with_request_options(self, options: RequestOptions) -> Self
pub fn with_request_options(self, options: RequestOptions) -> Self
Sets the request options that will be used when creating the multiplexed session for the client.
§Example
let spanner = Spanner::builder().build().await?;
let mut options = RequestOptions::default();
options.set_attempt_timeout(Duration::from_secs(60));
let database_client = spanner
.database_client("projects/my-project/instances/my-instance/databases/my-db")
.with_request_options(options)
.build()
.await?;Sourcepub fn with_leader_aware_routing(self, enabled: bool) -> Self
pub fn with_leader_aware_routing(self, enabled: bool) -> Self
Sets whether Leader-Aware Routing (LAR) is enabled for read/write transactions.
§Example
let spanner = Spanner::builder().build().await?;
let database_client = spanner
.database_client("projects/my-project/instances/my-instance/databases/my-db")
.with_leader_aware_routing(true)
.build()
.await?;When LAR is enabled, modifying operations (Read-Write, Write-Only, and Partitioned DML transactions) automatically route requests directly to the Spanner leader replica. This eliminates internal forwarding hops between replicas and reduces overall transaction latency.
Enabled by default.
See also: https://docs.cloud.google.com/spanner/docs/leader-aware-routing
Sourcepub async fn build(self) -> Result<DatabaseClient>
pub async fn build(self) -> Result<DatabaseClient>
Builds the DatabaseClient and creates a single multiplexed session that will be used for all operations on the database.
Auto Trait Implementations§
impl !RefUnwindSafe for DatabaseClientBuilder
impl !UnwindSafe for DatabaseClientBuilder
impl Freeze for DatabaseClientBuilder
impl Send for DatabaseClientBuilder
impl Sync for DatabaseClientBuilder
impl Unpin for DatabaseClientBuilder
impl UnsafeUnpin for DatabaseClientBuilder
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> 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