pub struct Client { /* private fields */ }Expand description
A client bound to one RPC proxy.
One connection multiplexes every call, so a Client is cheap to share:
wrap it in an Arc and call it concurrently rather than opening more.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn connect(address: &str) -> Result<Self>
pub async fn connect(address: &str) -> Result<Self>
Connects to an RPC proxy at host:port.
The address is the one discover_proxies returns, not the HTTP proxy’s.
Sourcepub fn builder(address: &str) -> ClientBuilder
pub fn builder(address: &str) -> ClientBuilder
Starts configuring a client.
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
The underlying connection, for callers that need to invoke a method this crate does not wrap.
Sourcepub async fn discover_proxies(&self, role: Option<&str>) -> Result<Vec<String>>
pub async fn discover_proxies(&self, role: Option<&str>) -> Result<Vec<String>>
The addresses of the cluster’s RPC proxies, asked of this one.
Sourcepub async fn start_transaction(
&self,
transaction_type: TransactionType,
options: StartTransactionOptions,
) -> Result<Transaction<'_>>
pub async fn start_transaction( &self, transaction_type: TransactionType, options: StartTransactionOptions, ) -> Result<Transaction<'_>>
Starts a transaction.
A tablet transaction is sticky: it belongs to the proxy that created
it, and every later call in it must go to that same proxy. This client
holds one connection, so that happens naturally — but a transaction
started here must not be used through another Client.
Sourcepub async fn lookup_rows(
&self,
path: &str,
columns: &[&str],
keys: &[Row],
options: LookupOptions<'_>,
) -> Result<Vec<MaybeRow>>
pub async fn lookup_rows( &self, path: &str, columns: &[&str], keys: &[Row], options: LookupOptions<'_>, ) -> Result<Vec<MaybeRow>>
Looks rows up by key.
keys holds one row per key, carrying only the key columns. The result
has one entry per key in the order asked, and a key with no row
comes back as None — which is why the rows are Options rather than a
shorter list.
Sourcepub async fn lookup_rows_with_columns(
&self,
path: &str,
columns: &[&str],
keys: &[Row],
options: LookupOptions<'_>,
) -> Result<(Vec<MaybeRow>, Vec<String>)>
pub async fn lookup_rows_with_columns( &self, path: &str, columns: &[&str], keys: &[Row], options: LookupOptions<'_>, ) -> Result<(Vec<MaybeRow>, Vec<String>)>
Looks rows up, returning the names of the columns as well as the rows.
A value carries a numeric id, not a name, and the reply’s descriptor is
what resolves them. Callers that map rows onto named columns — the
blocking facade, and anything building a serde row — need both.
Sourcepub async fn select_rows(
&self,
query: &str,
options: SelectOptions,
) -> Result<Vec<MaybeRow>>
pub async fn select_rows( &self, query: &str, options: SelectOptions, ) -> Result<Vec<MaybeRow>>
Runs a query and returns its rows.
The returned descriptor names the columns, in the order the values are
numbered; select_rows_with_columns
hands both back when the caller needs the names.
Sourcepub async fn select_rows_with_columns(
&self,
query: &str,
options: SelectOptions,
) -> Result<(Vec<MaybeRow>, Vec<String>)>
pub async fn select_rows_with_columns( &self, query: &str, options: SelectOptions, ) -> Result<(Vec<MaybeRow>, Vec<String>)>
Runs a query, returning its rows and the names of their columns.