Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support querying all locks with the same partition key #58

Open
lcabancla opened this issue Jul 21, 2021 · 0 comments
Open

Support querying all locks with the same partition key #58

lcabancla opened this issue Jul 21, 2021 · 0 comments

Comments

@lcabancla
Copy link
Contributor

lcabancla commented Jul 21, 2021

Support querying all locks with the same partition key.

The function signature can be similar to:

    /**
     * <p>
     * Retrieves the locks with partition_key = {@code key}.
     * </p>
     * <p>
     * Not that this may return a lock item even if it was released.
     * </p>
     *
     * @param key the partition key
     * @param deleteOnRelease Whether or not the {@link LockItem} should delete the item
     *                        when {@link LockItem#close()} is called on it.
     * @return A non parallel {@link Stream} of {@link LockItem}s that has the partition key in
     * DynamoDB. Note that the item can exist in the table even if it is
     * released, as noted by {@link LockItem#isReleased()}.
     */
    public Stream<LockItem> getLocksByPartitionKey(String key, final boolean deleteOnRelease) {

Currently the only way to get multiple leases is by scanning the table ie - via getAllLocksFromDynamoDB(). This is useful in cases where we only want to query a subset of the leases. For example, leases can be categorized and each lease in the same category has the same partition key but different sort keys.

Loading all leases by partition key should require an efficient query instead of a full scan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant