Module ydb_unofficial::client

source ·
Expand description

Common Ydb client, that wraps GRPC(s) transport with needed headers

§Examples

    let url = std::env::var("YDB_URL").expect("YDB_URL not set");
    let db_name = std::env::var("DB_NAME").expect("DB_NAME not set");
    let creds = std::env::var("DB_TOKEN").expect("DB_TOKEN not set");
 
    // how you can create service
    let endpoint = ydb_unofficial::client::create_endpoint(url.try_into().unwrap());
    let channel = endpoint.connect().await.unwrap();
    use ydb_unofficial::YdbConnection;
    let mut service = YdbConnection::new(channel, db_name.as_str().try_into().unwrap(), creds);
 
    // how to use it, e.g. use discovery service:
    use ydb_unofficial::generated::ydb::discovery::ListEndpointsRequest;
    let endpoints_response = service.discovery().list_endpoints(
        ListEndpointsRequest{
            database: db_name.into(), 
            ..Default::default()
        }
    ).await.unwrap();
     
    // how you can parse response to invoke result with YdbResponseWithResult trait
    use ydb_unofficial::YdbResponseWithResult;
    let endpoints_result = endpoints_response.get_ref().result().unwrap();
    assert!(endpoints_result.endpoints.len() > 0);
 
    // now to use table operations
    use ydb_unofficial::generated::ydb::table;
     

Structs§

Functions§