Expand description
Client that acquires distributed locks with an expiry (aka “leases”) using dynamodb & tokio runtime.
§Example
let client = dynamodb_lease::Client::builder()
.table_name("example-leases")
.lease_ttl_seconds(60)
.build_and_check_db(dynamodb_client)
.await?;
// acquire a lease for "important-job-123"
// waits for any other holders to release if necessary
let lease = client.acquire("important-job-123").await?;
// `lease` periodically extends itself in a background tokio task
// until dropped others will not be able to acquire this lease
assert!(client.try_acquire("important-job-123").await?.is_none());
// Dropping the lease will asynchronously release it, so others may acquire it
drop(lease);
Structs§
- Client
- Client for acquiring
Lease
s. - Client
Builder Client
builder.- Lease
- Represents a held distributed lease & background task to continuously try to extend it until dropped.