Skip to content

ArroyoSystems/dynamodb-lock-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dynamodb lock

Dynamodb based distributed lock implemented in pure Rust. The design is largely inspired by amazon-dynamodb-lock-client.

It is used by the delta-rs project to implement PUT if absence semantic for concurrent S3 writes. It is considered production ready and battle tested through the kafka-delta-ingest project.

Usage

let dynamodb_client = rusoto_dynamodb::DynamoDbClient::new(rusoto_core::Region::default());
let lock_client = dynamodb_lock::DynamoDbLockClient::new(
    dynamodb_client,
    dynamodb_lock::DynamoDbOptions::default(),
);

let lock_data = "Moe";
let lock = lock_client.try_acquire_lock(lock_data).await?.unwrap();

if lock.acquired_expired_lock {
    // error handling when acquired an expired lock
}

// do stuff in the critical region

lock_client.release_lock(&lock).await?;

For real world example, see https://github.com/delta-io/delta-rs/blob/main/rust/src/storage/s3/mod.rs.

About

Distributed lock backed by Dynamodb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%