Interface StreamProcessor<In,Out>
- Type Parameters:
In- the element type of the input sideOut- the element type of the output side
- All Superinterfaces:
Streamable<Out>, StreamSink<In>
- All Known Implementing Classes:
DispatchStreamProcessor
A
Flow.Processor-like interface combining the Streamable interface and the
StreamSink interface to establish a push-pull bridge based on CompletionStage-based
asynchronous processing and dispatching of values and errors.- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionReturns the terminalThrowableif thisStreamProcessorwas completed with aThrowableviaStreamSink.finish(Throwable).booleanbooleanbooleanReturnstrueif thisStreamProcessorwas completed with aThrowableviaStreamSink.finish(Throwable).intReturns the current number ofStreamers subscribed to thisStreamProcessorMethods inherited from interface Streamable
blockingFirst, blockingLast, collect, delay, doOnError, doOnNext, filter, flatMap, forEach, forEach, forEach, forEach, forEach, groupBy, hide, ignoreElements, intercept, last, lastOrError, lift, map, mapOptional, onErrorResumeNext, repeat, repeatWhen, retry, retry, retry, retryWhen, skip, stream, subscribe, subscribe, subscribe, subscribe, take, takeUntil, takeWhile, test, test, timeout, to, toFlowable, toFlowable, toObservable, transform, transformModifier and TypeMethodDescriptiondefault OutBlocks the current thread until thisStreamableproduces one item, which is then returned.default OutBlocks the current thread until thisStreamableproduces all of its items and the very last is then returned.default <A,R> @NonNull Streamable <R> Collects all upstream values via the use of aCollectorconfiguration and emits its resulting value as a single item of the returnedStreamable.default @NonNull Streamable<Out> Delays the delivery of each upstream item by the given time amount.default @NonNull Streamable<Out> Calls the specificConsumerif there is an error from the upstream.default @NonNull Streamable<Out> Calls the given consumer whenever an upstream item becomes available.default @NonNull Streamable<Out> Filters out the upstream items that do not pass the given predicate.default <R> @NonNull Streamable<R> flatMap(@NonNull Function<? super @NonNull Out, ? extends Streamable<? extends R>> mapper, @NonNull StandardConcurrentConfig config) Maps each upstream item onto aStreamableand runs them concurrently while relaying inner items as first-come-first-served manner.default @NonNull CompletionStageDisposable<Void> forEach(@NonNull BiConsumer<? super @NonNull Out, ? super Disposable> consumer, @NonNull DisposableStreamerCancellation canceller, @NonNull ExecutorService executor) Consumes elements from thisStreamablevia the provided executor service.default @NonNull CompletionStageDisposable<Void> Consumes elements from thisStreamablevia the provided executor service.default @NonNull CompletionStageDisposable<Void> forEach(@NonNull Consumer<? super @NonNull Out> consumer, @NonNull DisposableStreamerCancellation canceller) Consumes elements from thisStreamablevia the provided executor service.default @NonNull CompletionStageDisposable<Void> forEach(@NonNull Consumer<? super @NonNull Out> consumer, @NonNull DisposableStreamerCancellation canceller, @NonNull ExecutorService executor) Consumes elements from thisStreamablevia the provided executor service.default @NonNull CompletionStageDisposable<Void> Consumes elements from thisStreamablevia the provided executor service.default <@Nullable K>
@NonNull Streamable<GroupedStreamable<K, Out>> Maps each upstream item into aGroupedStreamablegroup, emits those groups and keeps relaying the upstream items into those groups.default @NonNull Streamable<Out> hide()Hides the identity of thisStreamableand itsStreamer.default @NonNull Streamable<Out> Ignores all elements from the currentStreamableand completes.default @NonNull Streamable<Out> intercept(StreamableInterceptConfig<@NonNull Out> config) Intercepts the lifecycle method calls ofStreamableandStreamerand allows the modification of them via Function callbacks.Signals the last item from the upstreamStreamableor the provideddefaultItemif the upstream is empty, as aSingleinstance.Signals the last item from the upstreamStreamableor aNoSuchElementExceptionif the upstream is empty, as aSingleinstance.default <@NonNull R>
@NonNull Streamable<R> This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns aStreamableinstance which when itsStreamable.stream(StreamerCancellation)is invoked, applies the specified operator callback to the upstreamStreamerto produce an actualStreamerinstance to be handed downstream.default <@NonNull R>
@NonNull Streamable<R> Maps each upstream item into another item via a mapper function.default <@NonNull R>
@NonNull Streamable<R> mapOptional(@NonNull Function<? super @NonNull Out, ? extends Optional<? extends @NonNull R>> mapper) Maps each upstream item into another, optional item via a mapper function that skips the empty optionals.default @NonNull Streamable<Out> onErrorResumeNext(@NonNull Function<? super Throwable, ? extends Streamable<? extends @NonNull Out>> fallbackMapper) When the upstream fails, the sequence is resumed by theStreamablethat is returned for the failureThrowable.default @NonNull Streamable<Out> repeat(long count) Runs the upstream at most the givencounttimes while it succeeds.default @NonNull Streamable<Out> repeatWhen(Function<? super Long, ? extends CompletionStage<Boolean>> whenFunction) Repeats the upstream when the given function signalstruevia theCompletionStagefor the count how many times the upstream was streamed.default @NonNull Streamable<Out> retry(long count) Retries at most the givencounttimes the upstream if it fails with any error.default @NonNull Streamable<Out> retry(BiPredicate<? super Long, ? super Throwable> predicate) Retries the upstream if the given predicate returnstruefor the failure count andThrowableof the last streaming of the upstream.default @NonNull Streamable<Out> Retries the upstream if the given predicate returnstruefor the failureThrowableof the last streaming of the upstream.default @NonNull Streamable<Out> retryWhen(BiFunction<? super Long, ? super Throwable, ? extends CompletionStage<Boolean>> whenFunction) Retries the upstream when the given predicate signalstruevia theCompletionStagefor the failure count andThrowableof the last streaming of the upstream.default @NonNull Streamable<Out> skip(long count) Skips the firstcountitems and relays the rest to the downstream.stream(@NonNull StreamerCancellation cancellation) Realizes the stream and returns an interface that lets one consume it.default @NonNull CompletionStage<Void> subscribe(@NonNull StreamSink<? super @NonNull Out> consumer) Relays the events of the upstream into aStreamSinkconsumer via the help of the standardExecutors.newVirtualThreadPerTaskExecutor()as a mediator for pull-to-push.default @NonNull CompletionStage<Void> subscribe(@NonNull StreamSink<? super @NonNull Out> consumer, ExecutorService executor) Relays the events of the upstream into aStreamSinkconsumer via the help of the givenExecutorServiceas a mediator for pull-to-push.default voidsubscribe(Flow.Subscriber<? super @NonNull Out> subscriber) Consume thisStreamablevia the given flow-reactive-streams subscriber on a virtual thread backed executor service.default voidsubscribe(Flow.Subscriber<? super @NonNull Out> subscriber, @NonNull ExecutorService executor) Consume thisStreamablevia the given flow-reactive-streams subscriber.default @NonNull Streamable<Out> take(long count) Takes at most the given number of items from the upstream and relays it to the downstream, then cancels the rest of the sequence.default <U> @NonNull Streamable<Out> takeUntil(@NonNull Streamable<U> other) Relays items from thisStreamableuntil the otherStreamablesignals an item or completes.default @NonNull Streamable<Out> Relays items from thisStreamablewhile the predicate returnstruedefault @NonNull TestSubscriber<Out> test()Creates a newTestSubscriberand subscribes it to thisStreamable.default @NonNull TestSubscriber<Out> test(@NonNull ExecutorService executor) Creates a newTestSubscriberand subscribes it to thisStreamable.default @NonNull Streamable<Out> timeout(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Streamable<@NonNull Out> fallback) Applies a timeout to each upstream item and switches to the fallbackStreamableif the upstream doesn't produce an item within the given timeout period.default <@NonNull R>
RCalls the specified converter function during assembly time and returns its resulting value.Converts the streamable into a Flowable representation, running on the default Executors.newVirtualThreadPerTaskExecutor() virtual thread.toFlowable(@NonNull ExecutorService executor) Converts thisStreamableinto aFlowablerepresentation, running on the provided executor service.default @NonNull Observable<Out> Converts thisStreamableinto aObservablerepresentation, emitting items on whatever thread produces items in the currentStreamable.default <@NonNull R>
@NonNull Streamable<R> Transforms the upstream sequence into zero or more elements for the downstream.default <@NonNull R>
@NonNull Streamable<R> transform(@NonNull VirtualTransformer<@NonNull Out, @NonNull R> transformer, @NonNull ExecutorService executor) Transforms the upstream sequence into zero or more elements for the downstream.Methods inherited from interface StreamSink
awaitFinish, awaitNext, cancellation, finish, next, withCancellationModifier and TypeMethodDescriptiondefault voidawaitFinish(Throwable throwable) Offer the final, terminal event and then awaits its consumption in a blocking fashion.default booleanOffers the given item and then awaits its consumption in a blocking fashion.Returns theDisposableContainerto use to detect if the consumer has indicated no more items it is willing to accept.Offer the final, terminal event.Offer the next item.default @NonNull StreamSink<In> withCancellation(DisposableStreamerCancellation cancellation) Returns a newStreamSinkthat returns the givenDisposableStreamerCancellationin itsStreamSink.cancellation(), allowing overriding the cancellation management of thisStreamSink
-
Method Details
-
hasStreamers
boolean hasStreamers()- Returns:
trueif thisStreamProcessorhasStreamers.
-
streamerCount
int streamerCount()Returns the current number ofStreamers subscribed to thisStreamProcessor- Returns:
- the current number of
Streamers subscribed to thisStreamProcessor
-
hasComplete
boolean hasComplete()- Returns:
trueif thisStreamProcessorwas completed normally viaStreamSink.finish(Throwable).
-
hasThrowable
boolean hasThrowable()Returnstrueif thisStreamProcessorwas completed with aThrowableviaStreamSink.finish(Throwable).- Returns:
trueif thisStreamProcessorwas completed with aThrowableviaStreamSink.finish(Throwable).
-
getThrowable
-