T- The type of objects being published
public class EnvelopeWrappedSdkPublisher<T> extends Object implements SdkPublisher<T>
The envelope prefix will not be published until the wrapped publisher publishes something or is completed. The envelope suffix will not be published until the wrapped publisher is completed.
This class can be used in an asynchronous interceptor in the AWS SDK to wrap content around the incoming bytestream from a response.
A function must be supplied that can be used to concatenate the envelope content with the content being published by
the wrapped publisher. Example usage:
Publisher<String> wrappedPublisher = ContentEnvelopeWrappingPublisher.of(publisher, "S", "E", (s1, s2) -> s1 + s2);
If publisher publishes a single string "1", wrappedPublisher will publish "S1" (prepending the envelop prefix). If
publisher then publishes a second string "2", wrappedPublisher will then publish "2" (no added content). If
publisher then completes, wrappedPublisher will then publish "E" and then complete.
WARNING: This publisher implementation does not comply with the complete flow spec (as it inserts data into the middle of a flow between a third-party publisher and subscriber rather than acting as a fully featured independent publisher) and therefore should only be used in a limited fashion when we have complete control over how data is being published to the publisher it wraps.
|Modifier and Type||Method and Description|
Create a new publisher that wraps the content of an existing publisher.
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static <T> EnvelopeWrappedSdkPublisher<T> of(org.reactivestreams.Publisher<T> wrappedPublisher, T contentPrefix, T contentSuffix, BiFunction<T,T,T> mergeContentFunction)
T- The content type.
wrappedPublisher- The publisher who's content will be wrapped.
contentPrefix- The content to be inserted in front of the wrapped content.
contentSuffix- The content to be inserted at the back of the wrapped content.
mergeContentFunction- A function that will be used to merge the inserted content into the wrapped content.
Copyright © 2020 Amazon Web Services, Inc. All Rights Reserved.