public interface SdkPublisher<T>
extends org.reactivestreams.Publisher<T>
Modifier and Type | Method and Description |
---|---|
static <T> SdkPublisher<T> |
adapt(org.reactivestreams.Publisher<T> toAdapt)
Adapts a
Publisher to SdkPublisher . |
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 invokes
Subscription.cancel() . |
default SdkPublisher<T> |
doAfterOnComplete(Runnable afterOnComplete)
Add a callback that will be invoked after this publisher invokes
Subscriber.onComplete() . |
default SdkPublisher<T> |
doAfterOnError(Consumer<Throwable> afterOnError)
Add a callback that will be invoked after this publisher invokes
Subscriber.onError(Throwable) . |
default <U extends T> |
filter(Class<U> clzz)
Filters published events to just those that are instances of the given class.
|
default SdkPublisher<T> |
filter(Predicate<T> predicate)
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.
|
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> |
map(Function<T,U> mapper)
Perform a mapping on the published events.
|
default CompletableFuture<Void> |
subscribe(Consumer<T> consumer)
Subscribes to the publisher with the given
Consumer . |
static <T> SdkPublisher<T> adapt(org.reactivestreams.Publisher<T> toAdapt)
Publisher
to SdkPublisher
.T
- Type of object being published.toAdapt
- Publisher
to adapt.default <U extends T> SdkPublisher<U> filter(Class<U> clzz)
Class
.U
- Type of class to filter to.clzz
- Class to filter to. Includes subtypes of the class.default SdkPublisher<T> filter(Predicate<T> predicate)
filter(Class)
, this method
does not change the type of the Publisher
.predicate
- Predicate to match events.default <U> SdkPublisher<U> map(Function<T,U> mapper)
U
- Type being mapped to.mapper
- Mapping function to apply.default <U> SdkPublisher<U> flatMapIterable(Function<T,Iterable<U>> mapper)
U
- Type of flattened event being mapped to.mapper
- Mapping function that produces an Iterable
of new events to be flattened.default SdkPublisher<List<T>> buffer(int bufferSize)
bufferSize
- Number of events to buffer before delivering downstream.default SdkPublisher<T> limit(int limit)
limit
- Number of events to publish.default SdkPublisher<T> doAfterOnComplete(Runnable afterOnComplete)
Subscriber.onComplete()
.afterOnComplete
- The logic that should be run immediately after onComplete.default SdkPublisher<T> doAfterOnError(Consumer<Throwable> afterOnError)
Subscriber.onError(Throwable)
.afterOnError
- The logic that should be run immediately after onError.default SdkPublisher<T> doAfterOnCancel(Runnable afterOnCancel)
Subscription.cancel()
.afterOnCancel
- The logic that should be run immediately after cancellation of the subscription.default CompletableFuture<Void> subscribe(Consumer<T> consumer)
Consumer
. 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 using Publisher.subscribe(Subscriber)
.consumer
- Consumer to process event.Copyright © 2021. All rights reserved.