#client #discovery #grpc #session #token #query #operation #ydb #load-balancing

ydb

Crate contains generated low-level grpc code from YDB API protobuf, used as base for ydb crate

38 releases

0.6.2 Aug 25, 2023
0.6.1 Jun 22, 2023
0.6.0 Mar 14, 2023
0.5.1 Dec 27, 2022
0.0.15 Mar 31, 2022
Download history 38/week @ 2023-05-31 18/week @ 2023-06-07 7/week @ 2023-06-14 67/week @ 2023-06-21 47/week @ 2023-06-28 10/week @ 2023-07-05 7/week @ 2023-07-12 21/week @ 2023-07-19 14/week @ 2023-07-26 4/week @ 2023-08-02 19/week @ 2023-08-09 45/week @ 2023-08-16 109/week @ 2023-08-23 7/week @ 2023-08-30 47/week @ 2023-09-06 5/week @ 2023-09-13

168 downloads per month
Used in ydb-steroids

Apache-2.0

565KB
12K SLoC

Rust YDB SDK Latest Version

Documentation

Rust SDK for YDB. Supported rust: 1.56.0 and newer.

Integration tests, with dependency from real YDB database mark as ignored. For run it:

  1. Set YDB_CONNECTION_STRING env
  2. run cargo test -- --ignored

lib.rs:

YDB SDK - a client for YDB.

Example

#

 // create driver
 let client = ClientBuilder::new_from_connection_string("grpc://localhost:2136?database=local")?
    .with_credentials(StaticToken::from("asd"))
    .client()?;

 // wait until driver background initialization finish
 client.wait().await?;

 // read query result
 let sum: i32 = client
    .table_client() // create table client
    .retry_transaction(|mut t| async move {
        // code in transaction can retry few times if was some retriable error

        // send query to database
        let res = t.query(Query::from("SELECT 1 + 1 AS sum")).await?;

        // read exact one result from db
        let field_val: i32 = res.into_only_row()?.remove_field_by_name("sum")?.try_into()?;

        // return result
        return Ok(field_val);
    })
    .await?;

 // it will print "sum: 2"
 println!("sum: {}", sum);

More examples

Url shorneter application

Many small examples

Dependencies

~22–38MB
~674K SLoC