-
Notifications
You must be signed in to change notification settings - Fork 910
Add new AsyncResponseTransformer: toPublisher() #2837
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
Conversation
## Motivation AsyncResponseTransformer currently lacks a static factory method that would allow a user to stream the response body data. The only methods currently available are toFile() and toBytes(). This lacks parity when compared to AsyncRequestBody#fromPublisher(), which allows declaring a body from an arbitrary ByteBuffer Publisher, and the sync client equivalent, ResponseTransformer#toInputStream(), which streams a response body to an InputStream.
SonarCloud Quality Gate failed. |
@Bennett-Lynch |
@Bennett-Lynch |
Hi @pkgonan. I don't have an estimate to share at this time, but if this is a feature you could benefit from, please let me know and I will try to find cycles to prioritize it. In the meantime, if you need the functionality immediately, you should be able to copy the classes that were introduced in this PR. These changes don't require any substantial changes to the inner workings of the SDK and instead are a mostly standalone and pluggable implementation of the |
@Bennett-Lynch Hi. Yes I need this feature. We are considering this feature in new projects. Therefore, I was constantly checking the progress of this PR. |
...-core/src/main/java/software/amazon/awssdk/core/async/NotifyingAsyncResponseTransformer.java
Outdated
Show resolved
Hide resolved
...t/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java
Show resolved
Hide resolved
.../main/java/software/amazon/awssdk/core/internal/async/PublisherAsyncResponseTransformer.java
Show resolved
Hide resolved
...src/main/java/software/amazon/awssdk/core/async/listen/AsyncResponseTransformerListener.java
Outdated
Show resolved
Hide resolved
core/sdk-core/src/main/java/software/amazon/awssdk/core/async/ResponsePublisher.java
Show resolved
Hide resolved
core/sdk-core/src/main/java/software/amazon/awssdk/core/async/listener/SubscriberListener.java
Outdated
Show resolved
Hide resolved
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.
Can we make sure integ tests pass before merging?
SonarCloud Quality Gate failed. |
This change has been released as part of version |
@Bennett-Lynch When using this feature, the LeasedConcurrency metric will continue to rise. Perhaps there is a leak in your connection. |
…69a1f8ffe Pull request: release <- staging/03e02562-7185-4eda-ba03-71c69a1f8ffe
Description
Add new
AsyncResponseTransformer
:toPublisher()
. This transformer makes it more convenient for users to directly consume a streaming-response payload (i.e., S3 GetObject) with async clients. This also allows users of Reactor/RxJava to more easily consume a streaming response (e.g., viaFlux#from(Publisher)
).Motivation and Context
AsyncResponseTransformer
currently lacks a static factory method that would allow a user to stream the response body data. The only methods currently available aretoFile()
andtoBytes()
. This lacks parity when compared toAsyncRequestBody#fromPublisher()
, which allows declaring a request body from an arbitraryPublisher<ByteBuffer>
. It also lacks parity when compared to the sync client's response equivalent,ResponseTransformer#toInputStream()
, which streams a response body to anInputStream
.Related Issues
Modifications
AsyncResponseTransformer#toPublisher()
static factory method that publishes the response body content through aResponsePublisher
, which is anSdkPublisher
that also contains a reference to theSdkResponse
returned by the service.NotifyingAsyncResponseTransformer
from being a TM-internal-API to a SDK-protected-API. RefactorNotifyingAsyncResponseTransformer
into 3 separate listeners interfaces:AsyncResponseTransformerListener
,PublisherListener
,SubscriberListener
. Each listener type allows wrapping the associated interface to listen in on events during the request/response lifecycle. Also convertNotifyingAsyncRequestBody
to SDK-protectedAsyncRequestBodyListener
.TransferManager
'sTransferProgressUpdater
to use the new transformer-listener logic to notify of acompletedTransfer
only after stream completion. UpdateTransferManager
'sTransferListenerInvoker
to guarantee one-time callback execution, now that there are multiple possible origins of success and failure.TransferManager
andS3AsyncClient
using the newtoPublisher
feature.License