Interface SdkPublisher<T>
- All Superinterfaces:
org.reactivestreams.Publisher<T>
- All Known Subinterfaces:
AsyncRequestBody,CloseableAsyncRequestBody,SubAsyncRequestBody
- All Known Implementing Classes:
AsyncRequestBodyListener.NotifyingAsyncRequestBody,BlockingInputStreamAsyncRequestBody,BlockingOutputStreamAsyncRequestBody,BufferedSplittableAsyncRequestBody,ByteArraySplittingTransformer,ByteBuffersAsyncRequestBody,ChecksumCalculatingAsyncRequestBody,ChecksumValidatingPublisher,CompressionAsyncRequestBody,EnvelopeWrappedSdkPublisher,FileAsyncRequestBody,FileAsyncResponseTransformerPublisher,InputStreamWithExecutorAsyncRequestBody,NonRetryableSubAsyncRequestBody,PaginatedItemsPublisher,PublisherListener.NotifyingPublisher,ResponsePublisher,RetryableSubAsyncRequestBody,SplittingPublisher,SplittingTransformer
Interface that is implemented by the Async auto-paginated responses.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SdkPublisher<T>adapt(org.reactivestreams.Publisher<T> toAdapt) Adapts aPublishertoSdkPublisher.default SdkPublisher<T>addTrailingData(Supplier<Iterable<T>> trailingDataSupplier) Creates a new publisher that emits trailing events provided bytrailingDataSupplierin addition to the published events.default SdkPublisher<List<T>>buffer(int bufferSize) Buffers the events into lists of the given buffer size.default SdkPublisher<T>doAfterOnCancel(Runnable afterOnCancel) Add a callback that will be invoked after this publisher invokesSubscription.cancel().default SdkPublisher<T>doAfterOnComplete(Runnable afterOnComplete) Add a callback that will be invoked after this publisher invokesSubscriber.onComplete().default SdkPublisher<T>doAfterOnError(Consumer<Throwable> afterOnError) Add a callback that will be invoked after this publisher invokesSubscriber.onError(Throwable).default <U extends T>
SdkPublisher<U>Filters published events to just those that are instances of the given class.default SdkPublisher<T>Filters published events to just those that match the given predicate.default <U> SdkPublisher<U>flatMapIterable(Function<T, Iterable<U>> mapper) Performs a mapping on the published events and creates a new publisher that emits the mapped events one by one.static <T> SdkPublisher<T>fromIterable(Iterable<T> iterable) Create anSdkPublisherfrom anIterable.default SdkPublisher<T>limit(int limit) Limit the number of published events and cancel the subscription after that limit has been reached.default <U> SdkPublisher<U>Perform a mapping on the published events.default CompletableFuture<Void>Subscribes to the publisher with the givenConsumer.Methods inherited from interface org.reactivestreams.Publisher
subscribe
-
Method Details
-
adapt
Adapts aPublishertoSdkPublisher.- Type Parameters:
T- Type of object being published.- Parameters:
toAdapt-Publisherto adapt.- Returns:
- SdkPublisher
-
fromIterable
Create anSdkPublisherfrom anIterable.- Type Parameters:
T- Type of object being published.- Parameters:
iterable-Iterableto adapt.- Returns:
- SdkPublisher
-
filter
Filters published events to just those that are instances of the given class. This changes the type of publisher to the type specified in theClass.- Type Parameters:
U- Type of class to filter to.- Parameters:
clzz- Class to filter to. Includes subtypes of the class.- Returns:
- New publisher, filtered to the given class.
-
filter
Filters published events to just those that match the given predicate. Unlikefilter(Class), this method does not change the type of thePublisher.- Parameters:
predicate- Predicate to match events.- Returns:
- New publisher, filtered to just the events that match the predicate.
-
map
Perform a mapping on the published events. Returns a new publisher of the mapped events. Typically this method will change the type of the publisher.- Type Parameters:
U- Type being mapped to.- Parameters:
mapper- Mapping function to apply.- Returns:
- New publisher with events mapped according to the given function.
-
flatMapIterable
Performs a mapping on the published events and creates a new publisher that emits the mapped events one by one.- Type Parameters:
U- Type of flattened event being mapped to.- Parameters:
mapper- Mapping function that produces anIterableof new events to be flattened.- Returns:
- New publisher of flattened events.
-
buffer
Buffers the events into lists of the given buffer size. Note that the last batch of events may be less than the buffer size.- Parameters:
bufferSize- Number of events to buffer before delivering downstream.- Returns:
- New publisher of buffered events.
-
limit
Limit the number of published events and cancel the subscription after that limit has been reached. The limit may never be reached if the downstream publisher doesn't have many events to publish. Once it reaches the limit, subsequent requests will be ignored.- Parameters:
limit- Number of events to publish.- Returns:
- New publisher that will only publish up to the specified number of events.
-
addTrailingData
Creates a new publisher that emits trailing events provided bytrailingDataSupplierin addition to the published events.- Parameters:
trailingDataSupplier- supplier to provide the trailing data- Returns:
- New publisher that will publish additional events
-
doAfterOnComplete
Add a callback that will be invoked after this publisher invokesSubscriber.onComplete().- Parameters:
afterOnComplete- The logic that should be run immediately after onComplete.- Returns:
- New publisher that invokes the requested callback.
-
doAfterOnError
Add a callback that will be invoked after this publisher invokesSubscriber.onError(Throwable).- Parameters:
afterOnError- The logic that should be run immediately after onError.- Returns:
- New publisher that invokes the requested callback.
-
doAfterOnCancel
Add a callback that will be invoked after this publisher invokesSubscription.cancel().- Parameters:
afterOnCancel- The logic that should be run immediately after cancellation of the subscription.- Returns:
- New publisher that invokes the requested callback.
-
subscribe
Subscribes to the publisher with the givenConsumer. This consumer will be called for each event published. There is no backpressure using this method if the Consumer dispatches processing asynchronously. If more control over backpressure is required, consider usingPublisher.subscribe(Subscriber).- Parameters:
consumer- Consumer to process event.- Returns:
- CompletableFuture that will be notified when all events have been consumed or if an error occurs.
-