-
Notifications
You must be signed in to change notification settings - Fork 914
Adding batchManager() method into code generated sync and async clients #2666
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
Adding batchManager() method into code generated sync and async clients #2666
Conversation
Allows for either an exception or response to be returned by the responseMapper. Also adding tests and option to specify batchKey and batchBuffer limits.
…ient's executor and ScheduledExecutor
…manager return type to customization config
…s' into feature/master/automatic-request-batching # Conflicts: # core/sdk-core/src/main/java/software/amazon/awssdk/core/batchmanager/BatchOverrideConfiguration.java # core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/BatchBuffer.java # core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/BatchConfiguration.java # core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/BatchingMap.java # core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/batchmanager/DefaultBatchManager.java # core/sdk-core/src/test/java/software/amazon/awssdk/core/internal/batchmanager/BatchManagerTest.java
…ort regular executor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to modify the customization config in sqs?
codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
Outdated
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
Outdated
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java
Outdated
Show resolved
Hide resolved
services/sqs/src/test/java/software/amazon/awssdk/services/sqs/SqsAsyncBatchManagerTest.java
Outdated
Show resolved
Hide resolved
...test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-async-class.java
Outdated
Show resolved
Hide resolved
.../test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-sync-class.java
Outdated
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
Show resolved
Hide resolved
codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
Outdated
Show resolved
Hide resolved
.../test/resources/software/amazon/awssdk/codegen/poet/client/test-batchmanager-sync-class.java
Outdated
Show resolved
Hide resolved
Sonarcloud fails due to 4 lines of duplicated code across the SyncClientInterface and AsyncClientInterface. The duplicated code just gets the batchManagerMethod which and adds it. |
codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
Show resolved
Hide resolved
...n/java/software/amazon/awssdk/services/sqs/internal/batchmanager/DefaultSqsBatchManager.java
Outdated
Show resolved
Hide resolved
@@ -134,7 +134,7 @@ static Builder builder() { | |||
* @param executor the executor to be used. | |||
* @returna reference to this object so that method calls can be chained together. | |||
*/ | |||
Builder executor(Executor executor); | |||
Builder executor(ExecutorService executor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why did we revert it back to Executor ExecutorService? If lack of shutdown is the reason, we can cast the created executor to executor service and call shutdown. https://github.com/aws/aws-sdk-java-v2/blob/master/utils/src/main/java/software/amazon/awssdk/utils/AttributeMap.java#L91-L93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally changed it to Executor
when I was trying to access the client's FUTURE_COMPLETION_EXECUTOR
. Since they sync client doesn't have that executor, it was ok to revert back to an ExecutorService
.
Kudos, SonarCloud Quality Gate passed! |
Motivation and Context
Users should have the option to be able to create a
batchManager()
directly from a low level sqs client as outlined in the design document. Changes also had to be made to the generated clients to ensure that they contained the necessary executor/scheduledExecutor that would be used by thebatchManager
.Description
Added some changes to how the sync and async clients (as well as their corresponding interfaces) are generated. Specifically added in the
batchManager()
method to create abatchManager
for that service.Executors
andScheduledExecutors
were also added to the underlying clients if they supported thebatchManager()
method.Testing
Added some codegen tests to check the generated classes and interfaces matched expectations. Also modified existing SqsBatchManager tests to use the client's batchManager instead of creating one separately.
Types of changes
Checklist
mvn install
succeedsLicense