awslabs / amazon-dynamodb-lock-client

The AmazonDynamoDBLockClient is a general purpose distributed locking library built on top of DynamoDB. It supports both coarse-grained and fine-grained locking.
Other
472 stars 85 forks source link

Add getLocksByPartitionKey() #59

Closed lcabancla closed 2 years ago

lcabancla commented 3 years ago

Issue #, if available: 58

Description of changes:

Add the following method to the AmazonDynamoDBLockClient:

public Stream<LockItem> getLocksByPartitionKey(String key, final boolean deleteOnRelease)

This method queries LockItems having the same partition key (but different sort key). It does this by calling dynamoDB.query(this.queryRequest).

Currently, the only way to read multiple Lock Items from the database is by performing a scan. This change allows the client to query for a subset of the leases only based on the partition key.

kapilsingh5050 commented 2 years ago

Thanks for creating this PR!

justinwlin-amazon commented 2 years ago

The unnecessary import stubs need to be removed to pass the build checks. In the process of getting secondary approval for this PR, to be merged in too.

lcabancla commented 2 years ago

The unnecessary import stubs need to be removed to pass the build checks. In the process of getting secondary approval for this PR, to be merged in too.

I have removed the unnecessary stubs.