1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Rust client for [UDB](https://github.com/fahara02/udb) — a proto-driven gRPC
//! broker over multiple databases.
//!
//! ```no_run
//! use udb_client::{Metadata, UdbClient};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! 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());
//! # Ok(())
//! # }
//! ```
//!
//! # 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`].
// `tonic::Status` is a large error type, and clippy flags every fallible gRPC
// call for it. Boxing it would make this client's errors differ from the type
// every tonic user already handles, which is a worse trade than the move cost.
/// The RPC registry generated from the proto descriptor set.
///
/// Regenerate with `udb sdk generate --lang rust --out sdk`; CI fails if the
/// committed copy differs from what the descriptor produces.
/// Generated protobuf and tonic client types, nested by proto package.
///
/// The module tree is emitted by `build.rs` from the packages tonic actually
/// generated, so adding a service to the contract does not require editing a
/// hand-maintained list here.
pub use ;
pub use UdbClient;
pub use ;
pub use ;
pub use Metadata;