pub struct LeaseClient { /* private fields */ }Expand description
Shared lease-acquisition client for app-owned pull receivers.
Holds the fully-qualified …/commands/leases endpoint, the bearer token,
and a pooled HTTP client. The endpoint is built once at construction
via LeaseClient::from_base, so a base URL that cannot be a hierarchical
(HTTP(S)) URL fails at startup rather than being re-derived — and
misclassified as a transient error — on every poll.
LeaseClient::acquire returns this crate’s Result; each caller maps
it to its own error enum at the boundary.
Implementations§
Source§impl LeaseClient
impl LeaseClient
Sourcepub fn from_base(base: &Url, token: String) -> Option<Self>
pub fn from_base(base: &Url, token: String) -> Option<Self>
Build a lease client for a command-server base URL, appending the
commands/leases path segments once.
Returns None if base cannot be a hierarchical (HTTP(S)) URL —
callers surface that as their own startup config error so the permanent
misconfiguration fails fast instead of being retried on every poll.
Sourcepub async fn acquire(&self, request: &LeaseRequest) -> Result<Vec<LeaseInfo>>
pub async fn acquire(&self, request: &LeaseRequest) -> Result<Vec<LeaseInfo>>
Acquire leases: POST request with the bearer token and parse the
LeaseResponse. Transport, 408, 429, and 5xx failures are retryable;
other non-success statuses are permanent request rejections.
Sourcepub async fn acquire_with_token(
&self,
request: &LeaseRequest,
token: &str,
) -> Result<Vec<LeaseInfo>>
pub async fn acquire_with_token( &self, request: &LeaseRequest, token: &str, ) -> Result<Vec<LeaseInfo>>
Acquire leases with a caller-supplied token. Receivers use this for
file-backed token rotation; Self::acquire uses the configured token.
Trait Implementations§
Source§impl Clone for LeaseClient
impl Clone for LeaseClient
Source§fn clone(&self) -> LeaseClient
fn clone(&self) -> LeaseClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for LeaseClient
impl !UnwindSafe for LeaseClient
impl Freeze for LeaseClient
impl Send for LeaseClient
impl Sync for LeaseClient
impl Unpin for LeaseClient
impl UnsafeUnpin for LeaseClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more