pub struct Client { /* private fields */ }Expand description
Client for acquiring Leases.
Communicates with dynamodb to acquire, extend and delete distributed leases.
Local mutex locks are also used to eliminate db contention for usage within
a single Client instance or clone.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a new Client builder.
Sourcepub async fn try_acquire(&self, key: impl Into<String>) -> Result<Option<Lease>>
pub async fn try_acquire(&self, key: impl Into<String>) -> Result<Option<Lease>>
Tries to acquire a new Lease for the given key.
If this lease has already been acquired elsewhere Ok(None) is returned.
Does not wait to acquire a lease, to do so see Client::acquire.
Sourcepub async fn acquire(&self, key: impl Into<String>) -> Result<Lease>
pub async fn acquire(&self, key: impl Into<String>) -> Result<Lease>
Acquires a new Lease for the given key. May wait until successful if the lease
has already been acquired elsewhere.
To try to acquire without waiting see Client::try_acquire.
Sourcepub async fn acquire_timeout(
&self,
key: impl Into<String>,
max_wait: Duration,
) -> Result<Lease>
pub async fn acquire_timeout( &self, key: impl Into<String>, max_wait: Duration, ) -> Result<Lease>
Acquires a new Lease for the given key. May wait until successful if the lease
has already been acquired elsewhere up to a max of max_wait.
To try to acquire without waiting see Client::try_acquire.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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> 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