Class OutputStreamMulti
java.lang.Object
java.io.OutputStream
io.helidon.common.reactive.OutputStreamMulti
- All Implemented Interfaces:
Multi<ByteBuffer>, Subscribable<ByteBuffer>, Closeable, Flushable, AutoCloseable, Flow.Publisher<ByteBuffer>
Output stream that
Flow.Publisher publishes any data written to it as ByteBuffer
events.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate new output stream thatFlow.Publisherpublishes any data written to it asByteBufferevents. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()onRequest(BiConsumer<Long, Long> requestCallback) Callback executed when request signal from downstream arrive.voidsubscribe(Flow.Subscriber<? super ByteBuffer> subscriber) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class OutputStream
nullOutputStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Multi
collect, collect, collectList, collectStream, compose, defaultIfEmpty, defaultIfEmpty, distinct, dropWhile, filter, first, flatMap, flatMap, flatMapCompletionStage, flatMapIterable, flatMapIterable, flatMapOptional, forEach, forEachCompletionStage, ifEmpty, ignoreElements, limit, log, log, log, log, map, observeOn, observeOn, onCancel, onComplete, onCompleteResume, onCompleteResumeWith, onError, onErrorResume, onErrorResumeWith, onTerminate, peek, reduce, reduce, retry, retry, retryWhen, skip, switchIfEmpty, takeUntil, takeWhile, timeout, timeout, toModifier and TypeMethodDescriptiondefault <U> Single<U> collect(Collector<ByteBuffer, U> collector) default <U> Single<U> collect(Supplier<? extends U> collectionSupplier, BiConsumer<U, ByteBuffer> accumulator) default Single<List<ByteBuffer>> default <A,R> Single <R> collectStream(Collector<ByteBuffer, A, R> collector) Collects up upstream items with the help of a the callbacks of aCollector.default <U> Multi<U> compose(Function<? super Multi<ByteBuffer>, ? extends Flow.Publisher<? extends U>> composer) Apply the givencomposerfunction to the currentMultiinstance and return aMultiwrapping the returnedFlow.Publisherof this function.default Multi<ByteBuffer> defaultIfEmpty(Supplier<? extends ByteBuffer> supplier) Signals the default item supplied by specified supplier if the upstream is empty.default Multi<ByteBuffer> defaultIfEmpty(ByteBuffer defaultItem) Signals the default item if the upstream is empty.default Multi<ByteBuffer> distinct()Filter out all duplicates.default Multi<ByteBuffer> dropWhile(Predicate<? super ByteBuffer> predicate) Drop the longest prefix of elements from this stream that satisfy the given predicate.default Multi<ByteBuffer> filter(Predicate<? super ByteBuffer> predicate) Filter stream items with provided predicate.default Single<ByteBuffer> first()default <U> Multi<U> flatMap(Function<? super ByteBuffer, ? extends Flow.Publisher<? extends U>> publisherMapper) Transform item with supplied function and flatten resultingFlow.Publisherto downstream.default <U> Multi<U> flatMap(Function<? super ByteBuffer, ? extends Flow.Publisher<? extends U>> mapper, long maxConcurrency, boolean delayErrors, long prefetch) Transform item with supplied function and flatten resultingFlow.Publisherto downstream while limiting the maximum number of concurrent innerFlow.Publishers and their in-flight item count, optionally aggregating and delaying all errors until all sources terminate.default <U> Multi<U> flatMapCompletionStage(Function<? super ByteBuffer, ? extends CompletionStage<? extends U>> mapper) Transform item with supplied function and flatten resultingCompletionStageresults to downstream.default <U> Multi<U> flatMapIterable(Function<? super ByteBuffer, ? extends Iterable<? extends U>> iterableMapper) Transform item with supplied function and flatten resultingIterableto downstream.default <U> Multi<U> flatMapIterable(Function<? super ByteBuffer, ? extends Iterable<? extends U>> iterableMapper, int prefetch) Transform item with supplied function and flatten resultingIterableto downstream.default <U> Multi<U> flatMapOptional(Function<? super ByteBuffer, Optional<? extends U>> mapper) Transform item with supplied function and flatten resultingOptionalto downstream as one item if present or nothing if empty.forEach(Consumer<? super ByteBuffer> consumer) Terminal stage, invokes provided consumer for every item in the stream with no backpressure.forEachCompletionStage(Function<? super ByteBuffer, CompletionStage<Void>> function) Terminal stage, invokes provided consumer for every item in the stream with strict backpressure.default Multi<ByteBuffer> Executes givenRunnablewhen stream is finished without value(empty stream).Terminal stage, ignore all items and complete returnedSingle<Void>successfully or exceptionally.default Multi<ByteBuffer> limit(long limit) Limit stream to allow only specified number of items to pass.default Multi<ByteBuffer> log()Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.default Multi<ByteBuffer> Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.default Multi<ByteBuffer> Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.default Multi<ByteBuffer> Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.default <U> Multi<U> map(Function<? super ByteBuffer, ? extends U> mapper) default Multi<ByteBuffer> Re-emit the upstream's signals to the downstream on the given executor's thread using a default buffer size of 32 and errors skipping ahead of items.default Multi<ByteBuffer> Re-emit the upstream's signals to the downstream on the given executor's thread.default Multi<ByteBuffer> Executes givenRunnablewhen a cancel signal is received.default Multi<ByteBuffer> onComplete(Runnable onComplete) Executes givenRunnablewhen onComplete signal is received.default Multi<ByteBuffer> onCompleteResume(ByteBuffer item) Resume stream from single item if onComplete signal is intercepted.default Multi<ByteBuffer> onCompleteResumeWith(Flow.Publisher<? extends ByteBuffer> publisher) Resume stream from supplied publisher if onComplete signal is intercepted.default Multi<ByteBuffer> Executes givenRunnablewhen onError signal is received.default Multi<ByteBuffer> onErrorResume(Function<? super Throwable, ? extends ByteBuffer> onError) Functionproviding one item to be submitted as onNext in case of onError signal is received.default Multi<ByteBuffer> onErrorResumeWith(Function<? super Throwable, ? extends Flow.Publisher<? extends ByteBuffer>> onError) Resume stream from supplied publisher if onError signal is intercepted.default Multi<ByteBuffer> onTerminate(Runnable onTerminate) Executes givenRunnablewhen any of signals onComplete, onCancel or onError is received.default Multi<ByteBuffer> peek(Consumer<? super ByteBuffer> consumer) Invoke provided consumer for every item in stream.default Single<ByteBuffer> reduce(BiFunction<ByteBuffer, ByteBuffer, ByteBuffer> reducer) Combine subsequent items via a callback function and emit the final value result as a Single.default <R> Single<R> reduce(Supplier<? extends R> supplier, BiFunction<R, ByteBuffer, R> reducer) Combine every upstream item with an accumulator value to produce a new accumulator value and emit the final accumulator value as a Single.default Multi<ByteBuffer> retry(long count) Retry a failing upstream at most the given number of times before giving up.default Multi<ByteBuffer> retry(BiPredicate<? super Throwable, ? super Long> predicate) Retry a failing upstream if the predicate returns true.default <U> Multi<ByteBuffer> retryWhen(BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction) Retry a failing upstream when the given function returns a publisher that signals an item.default Multi<ByteBuffer> skip(long skip) Skip first n items, all the others are emitted.default Multi<ByteBuffer> switchIfEmpty(Flow.Publisher<ByteBuffer> other) Switch to the other publisher if the upstream is empty.default <U> Multi<ByteBuffer> takeUntil(Flow.Publisher<U> other) Relay upstream items until the other source signals an item or completes.default Multi<ByteBuffer> takeWhile(Predicate<? super ByteBuffer> predicate) Take the longest prefix of elements from this stream that satisfy the given predicate.default Multi<ByteBuffer> timeout(long timeout, TimeUnit unit, ScheduledExecutorService executor) Signals aTimeoutExceptionif the upstream doesn't signal the next item, error or completion within the specified time.default Multi<ByteBuffer> timeout(long timeout, TimeUnit unit, ScheduledExecutorService executor, Flow.Publisher<ByteBuffer> fallback) Switches to a fallback single if the upstream doesn't signal the next item, error or completion within the specified time.default <U> Uto(Function<? super Multi<ByteBuffer>, ? extends U> converter) Apply the givenconverterfunction to the currentMultiinstance and return the value returned by this function.Methods inherited from interface Subscribable
subscribe, subscribe, subscribe, subscribeModifier and TypeMethodDescriptiondefault voidsubscribe(Consumer<? super ByteBuffer> consumer) Subscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super ByteBuffer> consumer, Consumer<? super Throwable> errorConsumer) Subscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super ByteBuffer> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer) Subscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super ByteBuffer> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer, Consumer<? super Flow.Subscription> subscriptionConsumer) Subscribe to thisSingleinstance with the given delegate functions.
-
Constructor Details
-
OutputStreamMulti
protected OutputStreamMulti()Create new output stream thatFlow.Publisherpublishes any data written to it asByteBufferevents.
-
-
Method Details
-
onRequest
Callback executed when request signal from downstream arrive.- param
nthe requested count. - param
demandthe current total cumulative requested count, ranges between [0,Long.MAX_VALUE] where the max indicates that this publisher is unbounded.
- Parameters:
requestCallback- to be executed- Returns:
- this output stream multi
- param
-
subscribe
- Specified by:
subscribein interfaceFlow.Publisher<ByteBuffer>
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-