Expand description
Rust client for UDB — a proto-driven gRPC broker over multiple databases.
use udb_client::{Metadata, UdbClient};
let meta = Metadata::new("tenant-1")
.with_project("default")
.with_bearer_token(std::env::var("UDB_TOKEN")?);
let mut udb = UdbClient::connect("http://127.0.0.1:50051", meta).await?;
let set = udb
.select(udb_client::proto::udb::entity::v1::SelectRequest {
message_type: "myapp.v1.Invoice".into(),
..Default::default()
})
.await?;
println!("{} row(s)", set.rows.len());§Two listeners, two authorization models
UDB serves its data plane and its native services on SEPARATE listeners with
DIFFERENT authorization models — the data plane authorizes through Casbin,
the native services through scope-based endpoint security. A credential
accepted by one is not automatically accepted by the other, and the mismatch
surfaces as a permissions error rather than a wrong-address error. UdbClient
speaks to the data plane.
§Generated types
The stubs under proto are generated at build time from the protos rather
than committed, so this crate cannot drift from the contract it ships with.
They are laid out by proto package: udb.entity.v1 is
proto::udb::entity::v1.
Re-exports§
pub use auth::Token;pub use auth::TokenManager;pub use client::UdbClient;pub use error::CallPolicy;pub use error::UdbError;pub use generated_rpcs::is_retry_safe;pub use generated_rpcs::spec_for_path;pub use generated_rpcs::RpcSpec;pub use metadata::Metadata;