Skip to main content

UdbClient

Struct UdbClient 

Source
pub struct UdbClient { /* private fields */ }
Expand description

A connected UDB data-plane client bound to one identity.

Implementations§

Source§

impl UdbClient

Source

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.

Source

pub fn with_channel(channel: Channel, meta: Metadata) -> Self

Wrap an already-configured channel — use this for TLS, custom timeouts, load balancing, or interceptors.

Source

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.

Source

pub fn metadata(&self) -> &Metadata

The connection’s metadata.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_policy(&self, policy: CallPolicy) -> Self

Apply a deadline/retry policy to every call this client makes.

Source

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.

Source

pub async fn select( &mut self, req: SelectRequest, ) -> Result<RecordSet, UdbError>

Read. Retry policy comes from the contract, not this wrapper.

Source

pub async fn upsert( &mut self, req: UpsertRequest, ) -> Result<MutationResponse, UdbError>

Write. The contract declares it replayable, so it retries.

Source

pub async fn update( &mut self, req: UpdateRequest, ) -> Result<MutationResponse, UdbError>

Write. Contract-declared replayable.

Source

pub async fn delete( &mut self, req: DeleteRequest, ) -> Result<MutationResponse, UdbError>

Write. Contract-declared replayable.

Source

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.

Read.

Source

pub async fn vector_upsert( &mut self, req: VectorUpsertRequest, ) -> Result<MutationResponse, UdbError>

Write. Not contract-declared replayable.

Source

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§

Source§

impl Clone for UdbClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UdbClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more