-
Notifications
You must be signed in to change notification settings - Fork 916
DynamoDb mapper: non-blocking asynchronous support for all operations #1600
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
.changes/next-release/feature-AmazonDynamoDBEnhancedClientPreview-5c18892.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "feature", | ||
"category": "Amazon DynamoDB Enhanced Client [Preview]", | ||
"description": "Support for non-blocking asynchronous calling of all mapper operations" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...in/java/software/amazon/awssdk/extensions/dynamodb/mappingclient/AsyncMappedDatabase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.extensions.dynamodb.mappingclient; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.extensions.dynamodb.mappingclient.core.DynamoDbAsyncMappedDatabase; | ||
|
||
/** | ||
* Asynchronous interface for running commands against a DynamoDb database. See {@link DynamoDbAsyncMappedDatabase} for | ||
* an implementation of this interface that can statically created. | ||
*/ | ||
@SdkPublicApi | ||
public interface AsyncMappedDatabase { | ||
/** | ||
* Executes a command against the database. | ||
* | ||
* @param operation The operation to be performed in the context of the database. | ||
* @param <T> The expected return type from the operation. This is typically inferred by the compiler. | ||
* | ||
* @return A {@link CompletableFuture} of the result of the operation being executed. The documentation on the | ||
* operation itself should have more information. | ||
*/ | ||
<T> CompletableFuture<T> execute(DatabaseOperation<?, ?, T> operation); | ||
|
||
/** | ||
* Returns a mapped table that can be used to execute commands that work with mapped items against that table. | ||
* | ||
* @param tableName The name of the physical table persisted by DynamoDb. | ||
* @param tableSchema A {@link TableSchema} that maps the table to a modelled object. | ||
* @return A {@link AsyncMappedTable} object that can be used to execute table operations against. | ||
* @param <T> THe modelled object type being mapped to this table. | ||
*/ | ||
<T> AsyncMappedTable<T> table(String tableName, TableSchema<T> tableSchema); | ||
} |
84 changes: 84 additions & 0 deletions
84
.../main/java/software/amazon/awssdk/extensions/dynamodb/mappingclient/AsyncMappedIndex.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.extensions.dynamodb.mappingclient; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.core.async.SdkPublisher; | ||
|
||
/** | ||
* Asynchronous interface for running commands against an object that is linked to a specific DynamoDb secondary index | ||
* and knows how to map records from the table that index is linked to into a modelled object. | ||
* | ||
* @param <T> The type of the modelled object. | ||
*/ | ||
@SdkPublicApi | ||
public interface AsyncMappedIndex<T> { | ||
/** | ||
* Executes a command that is expected to return a single data item against the database with the context of the | ||
* specific table and secondary index this object is linked to. | ||
* | ||
* @param operationToPerform The operation to be performed in the context of the secondary index. | ||
* @param <R> The expected return type from the operation. This is typically inferred by the compiler. | ||
* @return A {@link CompletableFuture} of the result of the operation being executed. The documentation on the | ||
* operation itself should have more information. | ||
*/ | ||
<R> CompletableFuture<R> execute(IndexOperation<T, ?, ?, R> operationToPerform); | ||
|
||
/** | ||
* Executes a command that is expected to return a paginated list of data items against the database with the | ||
* context of the specific table and secondary index this object is linked to. | ||
* | ||
* @param operationToPerform The operation to be performed in the context of the secondary index. | ||
* @param <R> The expected return type from the operation. This is typically inferred by the compiler. | ||
* @return An {@link SdkPublisher} that will publish successive pages of result data items to any subscriber with | ||
* demand for them. | ||
*/ | ||
<R> SdkPublisher<R> execute(PaginatedIndexOperation<T, ?, ?, R> operationToPerform); | ||
|
||
/** | ||
* Gets the {@link MapperExtension} associated with this mapped resource. | ||
* @return The {@link MapperExtension} associated with this mapped resource. | ||
*/ | ||
MapperExtension mapperExtension(); | ||
|
||
/** | ||
* Gets the {@link TableSchema} object that this mapped table was built with. | ||
* @return The {@link TableSchema} object for this mapped table. | ||
*/ | ||
TableSchema<T> tableSchema(); | ||
|
||
/** | ||
* Gets the physical table name that operations performed by this object will be executed against. | ||
* @return The physical table name. | ||
*/ | ||
String tableName(); | ||
|
||
/** | ||
* Gets the physical secondary index name that operations performed by this object will be executed against. | ||
* @return The physical secondary index name. | ||
*/ | ||
String indexName(); | ||
|
||
/** | ||
* Creates a {@link Key} object from a modelled item. This key can be used in query conditionals and get | ||
* operations to locate a specific record. | ||
* @param item The item to extract the key fields from. | ||
* @return A key that has been initialized with the index values extracted from the modelled object. | ||
*/ | ||
Key keyFrom(T item); | ||
} |
64 changes: 64 additions & 0 deletions
64
.../main/java/software/amazon/awssdk/extensions/dynamodb/mappingclient/AsyncMappedTable.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.extensions.dynamodb.mappingclient; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.core.async.SdkPublisher; | ||
|
||
/** | ||
* Asynchronous interface for running commands against an object that is linked to a specific DynamoDb table resource | ||
* and therefore knows how to map records from that table into a modelled object. | ||
* | ||
* @param <T> The type of the modelled object. | ||
*/ | ||
@SdkPublicApi | ||
public interface AsyncMappedTable<T> extends MappedTableResource<T> { | ||
/** | ||
* Returns a mapped index that can be used to execute commands against a secondary index belonging to the table | ||
* being mapped by this object. Note that only a subset of the commands that work against a table will work | ||
* against a secondary index. | ||
* | ||
* @param indexName The name of the secondary index to build the command interface for. | ||
* @return An {@link AsyncMappedIndex} object that can be used to execute database commands against. | ||
*/ | ||
AsyncMappedIndex<T> index(String indexName); | ||
|
||
/** | ||
* Executes a command that is expected to return a single data item against the database with the context of the | ||
* primary index of the specific table this object is linked to. | ||
** | ||
* @param operationToPerform The operation to be performed in the context of the primary index of the table. | ||
* @param <R> The expected return type from the operation. This is typically inferred by the compiler. | ||
* | ||
* @return A {@link CompletableFuture} that will return the result of the operation being executed. The | ||
* documentation on the operation itself should have more information. | ||
*/ | ||
<R> CompletableFuture<R> execute(TableOperation<T, ?, ?, R> operationToPerform); | ||
|
||
/** | ||
* Executes a command that is expected to return a paginated list of data items against the database with the | ||
* context of the primary index of the specific table this object is linked to. | ||
** | ||
* @param operationToPerform The operation to be performed in the context of the primary index of the table. | ||
* @param <R> The expected return type from the operation. This is typically inferred by the compiler. | ||
* | ||
* @return An {@link SdkPublisher} that will publish successive pages of result data items to any subscriber with | ||
* demand for them. | ||
*/ | ||
<R> SdkPublisher<R> execute(PaginatedTableOperation<T, ?, ?, R> operationToPerform); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.