pub struct UdbClient { /* private fields */ }Expand description
A connected UDB data-plane client bound to one identity.
Implementations§
Source§impl UdbClient
impl UdbClient
Sourcepub async fn connect(
endpoint: impl Into<String>,
meta: Metadata,
) -> Result<Self, Error>
pub async fn connect( endpoint: impl Into<String>, meta: Metadata, ) -> Result<Self, Error>
Connect to a broker’s data-plane listener (:50051 by default).
Note the port: UDB runs SEPARATE listeners with different authorization models — the data plane authorizes through Casbin, while the native service listener uses scope-based endpoint security. A credential accepted by one is not automatically accepted by the other, and the mismatch presents as a permissions error rather than a wrong-address error.
Sourcepub fn with_channel(channel: Channel, meta: Metadata) -> Self
pub fn with_channel(channel: Channel, meta: Metadata) -> Self
Wrap an already-configured channel — use this for TLS, custom timeouts, load balancing, or interceptors.
Sourcepub fn with_token_manager(&self, tokens: TokenManager) -> Self
pub fn with_token_manager(&self, tokens: TokenManager) -> Self
A copy of this client whose calls carry the access token tokens owns,
renewed when stale, instead of the metadata’s static bearer.
When the broker refuses that token before its local expiry (a restarted
broker that lost the session, a revoked session), the client marks it,
renews it (refresh, else sign in again) and repeats the refused call
exactly once; the broker refuses authentication before any handler runs,
so a repeat cannot apply a write twice. A token renewed moments ago that
is refused again fails the call UNAUTHENTICATED. See crate::auth.
Sourcepub fn with_audit(
&self,
purpose: impl Into<String>,
correlation_id: impl Into<String>,
) -> Self
pub fn with_audit( &self, purpose: impl Into<String>, correlation_id: impl Into<String>, ) -> Self
A copy of this client carrying request-scoped audit fields.
Identity is intentionally not settable here; see Metadata.
Sourcepub fn with_bearer_token(&self, token: impl Into<String>) -> Self
pub fn with_bearer_token(&self, token: impl Into<String>) -> Self
Replace the bearer credential, e.g. after a token refresh.
The copy carries exactly this bearer: a TokenManager attached with
UdbClient::with_token_manager is dropped, and a refusal of a bearer
the client does not own is never renewed or repeated.
Sourcepub fn request<T>(&self, message: T) -> Result<Request<T>, Status>
pub fn request<T>(&self, message: T) -> Result<Request<T>, Status>
Wrap a message in a request carrying this connection’s metadata.
Public so callers can reach an RPC this wrapper does not expose yet
without hand-rolling — and without hand-rolling the headers. It carries
the metadata’s static bearer, not one a TokenManager owns.
Sourcepub fn raw(&mut self) -> &mut DataBrokerClient<Channel>
pub fn raw(&mut self) -> &mut DataBrokerClient<Channel>
The raw generated client, for RPCs this wrapper does not cover.
Pair it with UdbClient::request so metadata is still applied.
Sourcepub fn with_policy(&self, policy: CallPolicy) -> Self
pub fn with_policy(&self, policy: CallPolicy) -> Self
Apply a deadline/retry policy to every call this client makes.
Sourcepub async fn get_capabilities(
&mut self,
req: CapabilitiesRequest,
) -> Result<CapabilitiesResponse, UdbError>
pub async fn get_capabilities( &mut self, req: CapabilitiesRequest, ) -> Result<CapabilitiesResponse, UdbError>
Broker capabilities: a cheap authenticated read, also a warm-up and reachability probe.
Sourcepub async fn select(
&mut self,
req: SelectRequest,
) -> Result<RecordSet, UdbError>
pub async fn select( &mut self, req: SelectRequest, ) -> Result<RecordSet, UdbError>
Read. Retry policy comes from the contract, not this wrapper.
Sourcepub async fn upsert(
&mut self,
req: UpsertRequest,
) -> Result<MutationResponse, UdbError>
pub async fn upsert( &mut self, req: UpsertRequest, ) -> Result<MutationResponse, UdbError>
Write. The contract declares it replayable, so it retries.
Sourcepub async fn update(
&mut self,
req: UpdateRequest,
) -> Result<MutationResponse, UdbError>
pub async fn update( &mut self, req: UpdateRequest, ) -> Result<MutationResponse, UdbError>
Write. Contract-declared replayable.
Sourcepub async fn delete(
&mut self,
req: DeleteRequest,
) -> Result<MutationResponse, UdbError>
pub async fn delete( &mut self, req: DeleteRequest, ) -> Result<MutationResponse, UdbError>
Write. Contract-declared replayable.
Sourcepub async fn bulk_cas(
&mut self,
req: BulkCasRequest,
) -> Result<BulkCasResponse, UdbError>
pub async fn bulk_cas( &mut self, req: BulkCasRequest, ) -> Result<BulkCasResponse, UdbError>
Compare-and-swap. The contract does NOT declare it replayable: a CAS that timed out may have committed, and a repeat would compare against state its own first attempt wrote.
Sourcepub async fn vector_search(
&mut self,
req: VectorSearchRequest,
) -> Result<VectorSet, UdbError>
pub async fn vector_search( &mut self, req: VectorSearchRequest, ) -> Result<VectorSet, UdbError>
Read.
Sourcepub async fn vector_upsert(
&mut self,
req: VectorUpsertRequest,
) -> Result<MutationResponse, UdbError>
pub async fn vector_upsert( &mut self, req: VectorUpsertRequest, ) -> Result<MutationResponse, UdbError>
Write. Not contract-declared replayable.
Sourcepub async fn select_records(
&mut self,
req: SelectRequest,
) -> Result<Records, SelectError>
pub async fn select_records( &mut self, req: SelectRequest, ) -> Result<Records, SelectError>
Select and decode in one step.
Prefer this over UdbClient::select plus hand-decoding. The raw
RecordSet carries the records in records_json and sends the
rows field EMPTY for wire compatibility, and nothing in the generated
struct says which is which — so the natural-looking set.rows[i].fields
yields the right record COUNT with no data in it, and reports a populated
table as a page of empty entities. See crate::record.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UdbClient
impl !RefUnwindSafe for UdbClient
impl !UnwindSafe for UdbClient
impl Forget for UdbClient
impl Move for UdbClient
impl Send for UdbClient
impl Sync for UdbClient
impl Unpin for UdbClient
impl UnsafeUnpin for UdbClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request