Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

pub async fn connect(endpoints: Vec<String>) -> Result<Self, ClientError>

Source

pub fn cached_leader(&self) -> Option<String>

The endpoint the client currently believes is the leader, or None if no leader has been observed yet or the cached entry has aged past the configured leader_ttl.

Read-only diagnostic surface for ops dashboards and integration tests asserting that a client has converged to the expected leader. It reflects the cache as last updated by a completed RPC — it neither triggers nor waits on any network round-trip, and the TTL check is lazy (an expired entry reads as None).

Source

pub async fn get_ts(&self) -> Result<Timestamp, ClientError>

Source

pub async fn get_ts_batch( &self, count: u32, ) -> Result<Vec<Timestamp>, ClientError>

Source

pub async fn get_seq( &self, key: &str, count: u32, ) -> Result<SeqBlock, ClientError>

Request a contiguous block of count dense ordinals for the given sequence key.

Non-idempotent: if this call returns ClientError::SeqUncertain it means a commit may or may not have occurred on the server — do NOT silently retry, as that would risk spending a second block. The caller must resolve the ambiguity (e.g. by reading back the current counter with a coordinator-level read) before re-issuing.

All other errors are pre-commit-certain (the server rejected the request before any durable advance) and are safe to retry.

The client only pre-rejects universally-invalid inputs — an empty/oversized key and a zero count (a block always covers at least one ordinal). The upper bound on count is the server’s configured ServerBuilder::max_seq_count, which is deployment-specific, so the client does not second-guess it: an over-cap count is forwarded and the server rejects it with INVALID_ARGUMENT (surfaced as ClientError::Rpc). This keeps a client built against one cap correct against a server configured with another.

Source

pub async fn get_seq_batch( &self, entries: &[(&str, u32)], ) -> Result<Vec<SeqBlock>, ClientError>

Atomically request contiguous dense blocks for several DISTINCT keys in one round-trip. Returns one SeqBlock per entry, in request order.

Non-idempotent (whole batch): on ClientError::SeqUncertain the entire batch may or may not have committed — do NOT retry; reconcile first (the atomic server contract means it is all-or-nothing, so there is never a partial mix to untangle). All other errors are pre-commit-certain.

Client-side pre-checks reject only universally-invalid input: an empty batch, a duplicate key, an empty/oversized key, or a zero count. The per-entry count cap and the batch-size cap are server-side and are forwarded for the server to reject, so a client built against one configuration stays correct against a server with another.

Source

pub async fn get_current_max_safe(&self) -> Result<MaxSafe, ClientError>

Read the leader’s current safe-point in physical-millisecond units.

Targets the cached leader if known, otherwise the first configured endpoint. Followers return MaxSafe::max_safe_physical_ms == 0 rather than erroring, matching the proto contract; pollers needing freshness should target the leader endpoint.

Single-shot by design — the proto contract is “followers return 0” rather than NOT_LEADER, so there is no hint to chase and no worklist to drain; a caller polling for freshness retries the next tick rather than the next endpoint. The one (connect, RPC) pair is bounded by RetryPolicy::per_attempt_deadline (shared across both phases via PairBudget, exactly like one get_ts attempt), and a transport-class failure evicts the cached channel so a half-open / black-holing connection is dropped before the next poll lands on it.

Source

pub async fn acquire_lease( &self, holder: &[u8], holder_epoch: u64, ttl: Duration, ) -> Result<Lease, ClientError>

Acquire a stamping lease for an opaque holder group.

Single-attempt control-plane call: callers own retry and re-route policy. Retrying an ambiguous acquire is safe for the same (holder, holder_epoch) because the server treats that pair idempotently while the lease is live.

Source

pub async fn renew_lease( &self, lease_id: u64, ) -> Result<LeaseRenewal, ClientError>

Renew a live lease, re-arming its acquire-time TTL.

Single-attempt control-plane call; callers own retry and re-route policy.

Source

pub async fn release_lease(&self, lease_id: u64) -> Result<(), ClientError>

Release a lease. The server treats unknown or already-released leases as success, making graceful surrender idempotent.

Source

pub async fn get_safe_frontier(&self) -> Result<SafeFrontier, ClientError>

Read the lease-aware safe frontier in physical-millisecond units.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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