Crates.io | google-cloud-spanner |
lib.rs | google-cloud-spanner |
version | |
source | src |
created_at | 2021-11-26 05:29:13.887257+00 |
updated_at | 2025-02-05 03:00:12.083722+00 |
description | Google Cloud Platform spanner client library. |
homepage | |
repository | https://github.com/yoshidan/google-cloud-rust/tree/main/spanner |
max_upload_size | |
id | 487909 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Google Cloud Platform spanner library.
[dependencies]
google-cloud-spanner = "version"
Create Client
and call transaction API same as Google Cloud Go.
use google_cloud_spanner::client::Client;
use google_cloud_spanner::mutation::insert;
use google_cloud_spanner::statement::Statement;
use google_cloud_spanner::value::CommitTimestamp;
use google_cloud_spanner::client::Error;
#[tokio::main]
async fn main() -> Result<(), Error> {
const DATABASE: &str = "projects/local-project/instances/test-instance/databases/local-database";
// Create spanner client
let config = ClientConfig::default().with_auth().await.unwrap();
let mut client = Client::new(DATABASE, config).await.unwrap();
// Insert
let mutation = insert("Guild", &["GuildId", "OwnerUserID", "UpdatedAt"], &[&"guildId", &"ownerId", &CommitTimestamp::new()]);
let commit_timestamp = client.apply(vec![mutation]).await?;
// Read with query
let mut stmt = Statement::new("SELECT GuildId FROM Guild WHERE OwnerUserID = @OwnerUserID");
stmt.add_param("OwnerUserID",&"ownerId");
let mut tx = client.single().await?;
let mut iter = tx.query(stmt).await?;
while let Some(row) = iter.next().await? {
let guild_id = row.column_by_name::<String>("GuildId");
}
// Remove all the sessions.
client.close().await;
Ok(())
}
Result of the 24 hours Load Test.
Metrics | This library | Google Cloud Go |
---|---|---|
RPS | 438.4 | 443.4 |
Used vCPU | 0.37 ~ 0.42 | 0.65 ~ 0.70 |
Test condition