Struct dynamodb_lease::Client
source · 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>>
Trys 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.