public interface LazyFutureStream<U> extends FutureStream<U>, LazyToQueue<U>
exceptionSoftener| Modifier and Type | Method and Description |
|---|---|
default <T,R> LazyFutureStream<R> |
allOf(java.util.stream.Collector collector,
java.util.function.Function<T,R> fn) |
default <T,R> LazyFutureStream<R> |
allOf(java.util.function.Function<java.util.List<T>,R> fn)
React and allOf
allOf is a non-blocking equivalent of block.
|
default LazyFutureStream<U> |
capture(java.util.function.Consumer<? extends java.lang.Throwable> errorHandler)
React capture
While onFail is used for disaster recovery (when it is possible to
recover) - capture is used to capture those occasions where the full
pipeline has failed and is unrecoverable.
|
default <U> LazyFutureStream<U> |
cast(java.lang.Class<U> type) |
default LazyFutureStream<U> |
concat(java.util.stream.Stream<U> other)
Concatenate two streams.
|
default org.jooq.lambda.Seq<U> |
distinct() |
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> |
duplicate()
Duplicate a Streams into two equivalent Streams.
|
static <T> LazyFutureStream<T> |
empty() |
default LazyFutureStream<U> |
filter(java.util.function.Predicate<? super U> p)
Removes elements that do not match the supplied predicate from the
dataflow
|
default <R> LazyFutureStream<R> |
flatMap(java.util.function.Function<? super U,? extends java.util.stream.Stream<? extends R>> flatFn)
Allows aggregate values in a Stream to be flatten into a single Stream.
|
default <R> LazyFutureStream<R> |
fromStream(java.util.stream.Stream<R> stream) |
default <R> LazyFutureStream<R> |
fromStreamCompletableFuture(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
Construct a SimpleReactStream from provided Stream of CompletableFutures
|
static <T> LazyFutureStream<T> |
futureStream(java.lang.Iterable<T> iterable)
Wrap an Iterable into a FutureStream.
|
static <T> LazyFutureStream<T> |
futureStream(java.util.Iterator<T> iterator)
Wrap an Iterator into a FutureStream.
|
static <T> LazyFutureStream<T> |
futureStream(java.util.stream.Stream<T> stream)
Wrap a Stream into a FutureStream.
|
static LazyFutureStream<java.lang.Void> |
generate() |
static <T> LazyFutureStream<T> |
generate(java.util.function.Supplier<T> s) |
static <T> LazyFutureStream<T> |
generate(T value) |
default LazyFutureStream<U> |
intersperse(U value)
Returns a stream with a given value interspersed between any two values of this stream.
|
static <T> LazyFutureStream<T> |
iterate(T seed,
java.util.function.UnaryOperator<T> f) |
static LazyReact |
lazy(java.util.concurrent.ExecutorService executor) |
static LazyReact |
lazy(java.util.concurrent.ExecutorService executor,
com.nurkiewicz.asyncretry.RetryExecutor retry) |
static LazyReact |
lazy(com.nurkiewicz.asyncretry.RetryExecutor retry) |
default LazyFutureStream<U> |
limit(long maxSize) |
default LazyFutureStream<U> |
merge(SimpleReactStream<U> s)
Merge this reactive dataflow with another of the same type.
|
static <T> LazyFutureStream<T> |
of(T... values) |
static <T> LazyFutureStream<T> |
of(T value) |
default <U> FutureStream<U> |
ofType(java.lang.Class<U> type)
Keep only those elements in a stream that are of a given type.
|
default <U> LazyFutureStream<U> |
onFail(java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
React onFail
Define a function that can be used to recover from exceptions during the
preceeding stage of the dataflow.
|
static <U> LazyFutureStream<U> |
parallel(U... array)
Construct an Lazy SimpleReact Stream from specified array
|
static LazyReact |
parallelBuilder() |
static LazyReact |
parallelBuilder(int parallelism)
Construct a new LazyReact builder, with a new task executor and retry executor
with configured number of threads
|
static LazyReact |
parallelCommonBuilder() |
static <U> LazyFutureStream<U> |
parallelOf(U... array)
Construct a SimpleReact Stage from a supplied array
|
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> |
partition(java.util.function.Predicate<? super U> predicate)
Partition a stream into two given a predicate.
|
default LazyFutureStream<U> |
peek(java.util.function.Consumer<? super U> consumer)
Peek asynchronously at the results in the current stage.
|
default <R> LazyFutureStream<R> |
retry(java.util.function.Function<U,R> fn)
Will execute this phase on the RetryExecutor (default or user supplied).
|
static LazyReact |
sequentialBuilder() |
static LazyReact |
sequentialCommonBuilder() |
default LazyFutureStream<U> |
skip(long n) |
default <R> LazyFutureStream<R> |
then(java.util.function.Function<U,R> fn)
Override return type on SimpleReactStream
|
LazyFutureStream<U> |
withLastActive(StreamWrapper streamWrapper) |
allMatch, anyMatch, cast, close, collect, count, findAny, findFirst, flatMapToDouble, flatMapToInt, flatMapToLong, forEach, forEachOrdered, intersperse, isParallel, iterator, map, mapToDouble, mapToInt, mapToLong, max, merge, min, noneMatch, ofType, onClose, parallel, reduce, reduce, reduce, self, sequential, slice, slice, sorted, sorted, spliterator, stream, toArray, toArray, unorderedcast, concat, concat, concat, cycle, cycle, duplicate, foldLeft, foldLeft, foldRight, foldRight, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, intersperse, join, join, join, join, join, join, limit, limitUntil, limitUntil, limitWhile, limitWhile, maxBy, maxBy, minBy, minBy, ofType, partition, reverse, reverse, scanLeft, scanLeft, scanRight, scanRight, seq, seq, seq, seq, seq, shuffle, shuffle, shuffle, shuffle, skip, skipUntil, skipUntil, skipWhile, skipWhile, slice, splitAt, splitAt, splitAtHead, splitAtHead, toCollection, toCollection, toList, toList, toMap, toMap, toMap, toSet, toSet, toString, toString, toString, unfold, unzip, unzip, unzip, unzip, zip, zip, zip, zip, zipWithIndex, zipWithIndexassureSimpleReactException, futureStream, handleExceptions, lastActiveArray, merge, simple, simple, simple, streamCompletableFutures, withgetLastActive, getLazyCollector, getWaitStrategy, run, run, run, run, runOnCurrentaggregateResults, block, block, block, block, block, blockAndExtract, blockAndExtract, capture, collectResults, first, getSafe, last, submitAndBlockgetErrorHandler, getLastActive, getRetrier, getSimpleReact, getTaskExecutor, isEager, withEager, withErrorHandler, withLazyCollector, withQueueFactory, withRetrier, withTaskExecutor, withWaitStrategyisEager, toQueuegetQueueFactorygetQueueFactoryLazyFutureStream<U> withLastActive(StreamWrapper streamWrapper)
withLastActive in interface ConfigurableStream<U>default <R> LazyFutureStream<R> then(java.util.function.Function<U,R> fn)
then in interface EagerToQueue<U>then in interface FutureStream<U>then in interface LazyToQueue<U>then in interface SimpleReactStream<U>fn - Function to be applied to the results of the currently active
event tasksdefault LazyFutureStream<U> merge(SimpleReactStream<U> s)
SimpleReactStreammerge in interface FutureStream<U>merge in interface SimpleReactStream<U>s - Reactive stage builder to merge withdefault <U> LazyFutureStream<U> onFail(java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
SimpleReactStream
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 100, () -> 2, () -> 3)
.then(it -> {
if (it == 100)
throw new RuntimeException("boo!");
return it;
})
.onFail(e -> 1)
.then(it -> "*" + it)
.block();
In this example onFail recovers from the RuntimeException thrown when the
input to the first 'then' stage is 100.onFail in interface FutureStream<U>onFail in interface SimpleReactStream<U>fn - Recovery function, the exception is input, and the recovery
value is outputdefault LazyFutureStream<U> capture(java.util.function.Consumer<? extends java.lang.Throwable> errorHandler)
SimpleReactStream
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then(it -> it * 100)
.then(it -> {
if (it == 100)
throw new RuntimeException("boo!");
return it;
})
.onFail(e -> 1)
.then(it -> "*" + it)
.then(it -> {
if ("*200".equals(it))
throw new RuntimeException("boo!");
return it;
})
.capture(e -> logger.error(e.getMessage(),e))
.block();
In this case, strings will only contain the two successful results (for
()->1 and ()->3), an exception for the chain starting from Supplier
()->2 will be logged by capture. Capture will not capture the
exception thrown when an Integer value of 100 is found, but will catch
the exception when the String value "*200" is passed along the chain.capture in interface FutureStream<U>capture in interface SimpleReactStream<U>errorHandler - A consumer that recieves and deals with an unrecoverable error
in the dataflowdefault <T,R> LazyFutureStream<R> allOf(java.util.function.Function<java.util.List<T>,R> fn)
SimpleReactStream
boolean blocked[] = {false};
new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then(it -> {
try {
Thread.sleep(50000);
} catch (Exception e) {
}
blocked[0] =true;
return 10;
})
.allOf( it -> it.size());
assertThat(blocked[0],is(false));
In this example, the current thread will continue and assert that it is
not blocked, allOf could continue and be executed in a separate thread.allOf in interface FutureStream<U>allOf in interface SimpleReactStream<U>fn - Function that recieves the results of all currently active
tasks as inputdefault LazyFutureStream<U> peek(java.util.function.Consumer<? super U> consumer)
SimpleReactStreampeek in interface FutureStream<U>peek in interface org.jooq.lambda.Seq<U>peek in interface SimpleReactStream<U>peek in interface java.util.stream.Stream<U>consumer - That will recieve current resultsdefault LazyFutureStream<U> filter(java.util.function.Predicate<? super U> p)
SimpleReactStreamfilter in interface FutureStream<U>filter in interface org.jooq.lambda.Seq<U>filter in interface SimpleReactStream<U>filter in interface java.util.stream.Stream<U>p - Predicate that will be used to filter elements from the
dataflowdefault <R> LazyFutureStream<R> flatMap(java.util.function.Function<? super U,? extends java.util.stream.Stream<? extends R>> flatFn)
SimpleReactStreamflatMap in interface FutureStream<U>flatMap in interface org.jooq.lambda.Seq<U>flatMap in interface SimpleReactStream<U>flatMap in interface java.util.stream.Stream<U>flatFn - Function that coverts a value (e.g. a Collection) into a Streamdefault <R> LazyFutureStream<R> retry(java.util.function.Function<U,R> fn)
SimpleReactStreamretry in interface FutureStream<U>retry in interface SimpleReactStream<U>fn - Function that will be executed and retried on failuredefault <T,R> LazyFutureStream<R> allOf(java.util.stream.Collector collector, java.util.function.Function<T,R> fn)
allOf in interface EagerToQueue<U>allOf in interface FutureStream<U>allOf in interface LazyToQueue<U>allOf in interface SimpleReactStream<U>collector - to perform aggregation / reduction operation on the results
from active stage (e.g. to Collect into a List or String)fn - Function that receives the results of all currently active
tasks as inputdefault <R> LazyFutureStream<R> fromStream(java.util.stream.Stream<R> stream)
fromStream in interface FutureStream<U>fromStream in interface SimpleReactStream<U>default <R> LazyFutureStream<R> fromStreamCompletableFuture(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
SimpleReactStreamfromStreamCompletableFuture in interface FutureStream<U>fromStreamCompletableFuture in interface SimpleReactStream<U>stream - JDK Stream to construct new SimpleReactStream fromdefault LazyFutureStream<U> concat(java.util.stream.Stream<U> other)
concat in interface org.jooq.lambda.Seq<U>Seq.concat(Stream[])default <U> LazyFutureStream<U> cast(java.lang.Class<U> type)
cast in interface FutureStream<U>cast in interface org.jooq.lambda.Seq<U>default <U> FutureStream<U> ofType(java.lang.Class<U> type)
ofType in interface FutureStream<U>ofType in interface org.jooq.lambda.Seq<U>FutureStream.ofType(java.lang.Class)default LazyFutureStream<U> intersperse(U value)
intersperse in interface FutureStream<U>intersperse in interface org.jooq.lambda.Seq<U>Seq.intersperse(Stream, Object)default LazyFutureStream<U> limit(long maxSize)
default LazyFutureStream<U> skip(long n)
static <U> LazyFutureStream<U> parallel(U... array)
array - Values to react todefault org.jooq.lambda.Seq<U> distinct()
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> duplicate()
duplicate in interface org.jooq.lambda.Seq<U>Seq.duplicate(Stream)default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> partition(java.util.function.Predicate<? super U> predicate)
partition in interface org.jooq.lambda.Seq<U>Seq.partition(Stream, Predicate)static <U> LazyFutureStream<U> parallelOf(U... array)
parallelOf in interface SimpleReactStream<U>array - Array of value to form the reactive stream / sequencestatic LazyReact parallelBuilder()
parallelBuilder in interface SimpleReactStream<U>SimpleReact.SimpleReact()static LazyReact parallelBuilder(int parallelism)
parallelBuilder in interface SimpleReactStream<U>parallelism - Number of threads task executor should havestatic LazyReact parallelCommonBuilder()
parallelCommonBuilder in interface SimpleReactStream<U>see RetryBuilder#getDefaultInstance()static LazyReact sequentialBuilder()
sequentialBuilder in interface SimpleReactStream<U>static LazyReact sequentialCommonBuilder()
sequentialCommonBuilder in interface SimpleReactStream<U>static LazyReact lazy(java.util.concurrent.ExecutorService executor)
executor - Executor this SimpleReact instance will use to execute
concurrent tasks.static LazyReact lazy(com.nurkiewicz.asyncretry.RetryExecutor retry)
retry - RetryExecutor this SimpleReact instance will use to retry
concurrent tasks.static LazyReact lazy(java.util.concurrent.ExecutorService executor, com.nurkiewicz.asyncretry.RetryExecutor retry)
executor - Executor this SimpleReact instance will use to execute
concurrent tasks.retry - RetryExecutor this SimpleReact instance will use to retry
concurrent tasks.static <T> LazyFutureStream<T> of(T value)
of in interface org.jooq.lambda.Seq<U>of in interface SimpleReactStream<U>of in interface java.util.stream.Stream<U>Stream.of(Object)@SafeVarargs static <T> LazyFutureStream<T> of(T... values)
of in interface org.jooq.lambda.Seq<U>of in interface SimpleReactStream<U>of in interface java.util.stream.Stream<U>Stream.of(Object[])static <T> LazyFutureStream<T> empty()
empty in interface org.jooq.lambda.Seq<U>empty in interface SimpleReactStream<U>empty in interface java.util.stream.Stream<U>Stream.empty()static <T> LazyFutureStream<T> iterate(T seed, java.util.function.UnaryOperator<T> f)
static LazyFutureStream<java.lang.Void> generate()
generate in interface org.jooq.lambda.Seq<U>Stream.generate(Supplier)static <T> LazyFutureStream<T> generate(T value)
static <T> LazyFutureStream<T> generate(java.util.function.Supplier<T> s)
static <T> LazyFutureStream<T> futureStream(java.util.stream.Stream<T> stream)
futureStream in interface SimpleReactStream<U>static <T> LazyFutureStream<T> futureStream(java.lang.Iterable<T> iterable)
futureStream in interface SimpleReactStream<U>static <T> LazyFutureStream<T> futureStream(java.util.Iterator<T> iterator)
futureStream in interface SimpleReactStream<U>