Module 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§

TableClientWithSession
TableServiceClient with active session. for each method (that requires session_id) table client injects session_id field Session may be invalid. In this case you need to recreate that client with YdbConnection::table
YdbConnection
Ydb connection implementation, that pass database name and auth data to grpc channel
YdbEndpoint
YdbTransaction
TableServiceClient with active session and transaction

Functions§

create_endpoint
Creates endpoint from uri If protocol is grpcs, then creates tonic::transport::ClientTlsConfig and applies to Endpoint