public interface EagerFutureStream<U> extends FutureStream<U>, EagerToQueue<U>
exceptionSoftener| Modifier and Type | Method and Description |
|---|---|
default <T,R> EagerFutureStream<R> |
allOf(java.util.stream.Collector collector,
java.util.function.Function<T,R> fn) |
default <T,R> EagerFutureStream<R> |
allOf(java.util.function.Function<java.util.List<T>,R> fn)
React and allOf
allOf is a non-blocking equivalent of block.
|
default EagerFutureStream<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> EagerFutureStream<U> |
cast(java.lang.Class<U> type) |
default FutureStream<U> |
concat(SimpleReactStream<U> other) |
default EagerFutureStream<U> |
concat(java.util.stream.Stream<U> other)
Concatenate two streams.
|
default EagerFutureStream<U> |
concat(U... other)
Concatenate two streams.
|
default EagerFutureStream<U> |
concat(U other)
Concatenate two streams.
|
default EagerFutureStream<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.
|
default org.jooq.lambda.tuple.Tuple2<EagerFutureStream<U>,EagerFutureStream<U>> |
duplicateFutureStream()
Duplicate a Stream into two equivalent EagerFutureStreams
EagerFutureStream.of(1, 2, 3).duplicate()
results in
tuple((1,2,3),(1,2,3))
|
static EagerReact |
eagerBuilder(java.util.concurrent.ExecutorService executor) |
static EagerReact |
eagerBuilder(java.util.concurrent.ExecutorService executor,
com.nurkiewicz.asyncretry.RetryExecutor retry) |
static EagerReact |
eagerBuilder(com.nurkiewicz.asyncretry.RetryExecutor retry) |
static <T> EagerFutureStream<T> |
empty() |
default EagerFutureStream<U> |
filter(java.util.function.Predicate<? super U> p)
Removes elements that do not match the supplied predicate from the
dataflow
|
default <R> EagerFutureStream<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> EagerFutureStream<R> |
fromStream(java.util.stream.Stream<R> stream) |
default <R> EagerFutureStream<R> |
fromStreamCompletableFuture(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
Construct a SimpleReactStream from provided Stream of CompletableFutures
|
static <T> EagerFutureStream<T> |
futureStream(java.lang.Iterable<T> iterable)
Wrap an Iterable into a FutureStream.
|
static <T> EagerFutureStream<T> |
futureStream(java.util.Iterator<T> iterator)
Wrap an Iterator into a FutureStream.
|
static <T> EagerFutureStream<T> |
futureStream(java.util.stream.Stream<T> stream)
Wrap a Stream into a FutureStream.
|
default EagerFutureStream<U> |
intersperse(U value)
Returns a stream with a given value interspersed between any two values
of this stream.
|
default EagerFutureStream<U> |
limit(long maxSize) |
default EagerFutureStream<U> |
limitUntil(java.util.function.Predicate<? super U> predicate)
Returns a stream limited to all elements for which a predicate evaluates
to false.
|
default EagerFutureStream<U> |
limitWhile(java.util.function.Predicate<? super U> predicate)
Returns a stream limited to all elements for which a predicate evaluates
to true.
|
default EagerFutureStream<U> |
merge(SimpleReactStream<U> s)
Merge this reactive dataflow with another of the same type.
|
static <T> EagerFutureStream<T> |
of(T... values) |
static <T> EagerFutureStream<T> |
of(T value) |
default <U> EagerFutureStream<U> |
ofType(java.lang.Class<U> type)
Keep only those elements in a stream that are of a given type.
|
default <U> EagerFutureStream<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 EagerReact |
paraellelCommonBuilder() |
static <U> EagerFutureStream<U> |
parallel(U... array)
Construct an Eager SimpleReact Stream from specified array
|
static EagerReact |
parallelBuilder() |
static EagerReact |
parallelBuilder(int parallelism)
Construct a new EagerReact builder, with a new task executor and retry executor
with configured number of threads
|
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 org.jooq.lambda.tuple.Tuple2<EagerFutureStream<U>,EagerFutureStream<U>> |
partitionFutureStream(java.util.function.Predicate<? super U> predicate)
Partition an EagerFutureStream into two EagerFutureStreams given a predicate.
|
default EagerFutureStream<U> |
peek(java.util.function.Consumer<? super U> consumer)
Peek asynchronously at the results in the current stage.
|
default <R> EagerFutureStream<R> |
retry(java.util.function.Function<U,R> fn)
Will execute this phase on the RetryExecutor (default or user supplied).
|
default EagerFutureStream<U> |
reverse()
Reverse a stream.
|
default <T> EagerFutureStream<T> |
scanLeft(T seed,
java.util.function.BiFunction<T,? super U,T> function)
Scan a stream to the left.
|
default <R> EagerFutureStream<R> |
scanRight(R seed,
java.util.function.BiFunction<? super U,R,R> function)
Scan a stream to the right.
|
static EagerReact |
sequentialBuilder() |
static EagerReact |
sequentialCommonBuilder() |
default EagerFutureStream<U> |
shuffle()
Shuffle a stream
// e.g.
|
default EagerFutureStream<U> |
shuffle(java.util.Random random)
Shuffle a stream using specified source of randomness
// e.g.
|
default EagerFutureStream<U> |
skip(long n) |
default EagerFutureStream<U> |
skipUntil(java.util.function.Predicate<? super U> predicate)
Returns a stream with all elements skipped for which a predicate
evaluates to false.
|
default EagerFutureStream<U> |
skipWhile(java.util.function.Predicate<? super U> predicate)
Returns a stream with all elements skipped for which a predicate
evaluates to true.
|
default EagerFutureStream<U> |
slice(long from,
long to)
Returns a limited interval from a given Stream.
|
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> |
splitAt(long position)
Split a stream at a given position.
|
default org.jooq.lambda.tuple.Tuple2<EagerFutureStream<U>,EagerFutureStream<U>> |
splitAtFutureStream(long position)
Split a EagerFutureStream at a given position.
|
default org.jooq.lambda.tuple.Tuple2<java.util.Optional<U>,org.jooq.lambda.Seq<U>> |
splitAtHead()
Split a stream at the head.
|
default org.jooq.lambda.tuple.Tuple2<java.util.Optional<U>,EagerFutureStream<U>> |
splitAtHeadFutureStream()
SplitAtHead but return type is EagerFutureStream
|
default <R> EagerFutureStream<R> |
then(java.util.function.Function<U,R> fn)
React then
Unlike 'with' this method is fluent, and returns another Stage Builder
that can represent the next stage in the dataflow.
|
default <R> EagerFutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> |
zip(org.jooq.lambda.Seq<R> other)
Zip two streams into one.
|
default <T,R> EagerFutureStream<R> |
zip(org.jooq.lambda.Seq<T> other,
java.util.function.BiFunction<U,T,R> zipper)
Zip two streams into one using a
BiFunction to produce resulting
values. |
default EagerFutureStream<org.jooq.lambda.tuple.Tuple2<U,java.lang.Long>> |
zipWithIndex()
Zip a Stream with a corresponding Stream of indexes.
|
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, sorted, sorted, spliterator, stream, toArray, toArray, unorderedcast, concat, cycle, cycle, duplicate, foldLeft, foldLeft, foldRight, foldRight, generate, generate, generate, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, intersperse, iterate, join, join, join, join, join, join, limit, limitUntil, limitWhile, maxBy, maxBy, minBy, minBy, ofType, partition, reverse, scanLeft, scanRight, seq, seq, seq, seq, seq, shuffle, shuffle, skip, skipUntil, skipWhile, slice, splitAt, splitAtHead, toCollection, toCollection, toList, toList, toMap, toMap, toMap, toSet, toSet, toString, toString, toString, unfold, unzip, unzip, unzip, unzip, zip, zip, zipWithIndexassureSimpleReactException, futureStream, handleExceptions, lastActiveArray, merge, parallelCommonBuilder, parallelOf, 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, withLastActive, withLazyCollector, withQueueFactory, withRetrier, withTaskExecutor, withWaitStrategyisEager, toQueuegetQueueFactorygetQueueFactorydefault <R> EagerFutureStream<R> then(java.util.function.Function<U,R> fn)
SimpleReactStream
new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then((it) -> it * 100)
.then((it) -> "*" + it)
React then allows event reactors to be chained. Unlike React with, which
returns a collection of Future references, React then is a fluent
interface that returns the React builder - allowing further reactors to
be added to the chain.
React then does not block.
React with can be called after React then which gives access to the full
CompleteableFuture api. CompleteableFutures can be passed back into
SimpleReact via SimpleReact.react(streamOfCompleteableFutures);
See this blog post for examples of what can be achieved via
CompleteableFuture :- http://www.nurkiewicz.com/2013/12/promises-and-completablefuture.htm
l 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 EagerFutureStream<U> merge(SimpleReactStream<U> s)
SimpleReactStreammerge in interface FutureStream<U>merge in interface SimpleReactStream<U>s - Reactive stage builder to merge withdefault <U> EagerFutureStream<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 EagerFutureStream<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> EagerFutureStream<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 EagerFutureStream<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 EagerFutureStream<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> EagerFutureStream<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> EagerFutureStream<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> EagerFutureStream<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> EagerFutureStream<R> fromStream(java.util.stream.Stream<R> stream)
fromStream in interface FutureStream<U>fromStream in interface SimpleReactStream<U>default <R> EagerFutureStream<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 EagerFutureStream<U> limit(long maxSize)
default <U> EagerFutureStream<U> cast(java.lang.Class<U> type)
cast in interface FutureStream<U>cast in interface org.jooq.lambda.Seq<U>default <U> EagerFutureStream<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 EagerFutureStream<U> skip(long n)
default EagerFutureStream<U> concat(java.util.stream.Stream<U> other)
concat in interface org.jooq.lambda.Seq<U>Seq.concat(Stream[])default FutureStream<U> concat(SimpleReactStream<U> other)
default EagerFutureStream<U> concat(U other)
concat in interface org.jooq.lambda.Seq<U>Seq.concat(Stream[])default EagerFutureStream<U> concat(U... other)
concat in interface org.jooq.lambda.Seq<U>Seq.concat(Stream[])default EagerFutureStream<U> slice(long from, long to)
slice in interface FutureStream<U>slice in interface org.jooq.lambda.Seq<U>Seq.slice(Stream, long, long)default <R> EagerFutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> zip(org.jooq.lambda.Seq<R> other)
zip in interface org.jooq.lambda.Seq<U>Seq.zip(Stream, Stream)default <T,R> EagerFutureStream<R> zip(org.jooq.lambda.Seq<T> other, java.util.function.BiFunction<U,T,R> zipper)
BiFunction to produce resulting
values.
// ("1:a", "2:b", "3:c")
EagerFutureStream.of(1, 2, 3).zip(EagerFutureStream.of("a", "b", "c"), (i, s) > i + ":" + s)zip in interface org.jooq.lambda.Seq<U>zip(Seq, BiFunction)default EagerFutureStream<org.jooq.lambda.tuple.Tuple2<U,java.lang.Long>> zipWithIndex()
zipWithIndex in interface org.jooq.lambda.Seq<U>Seq.zipWithIndex(Stream)default <T> EagerFutureStream<T> scanLeft(T seed, java.util.function.BiFunction<T,? super U,T> function)
scanLeft in interface org.jooq.lambda.Seq<U>default <R> EagerFutureStream<R> scanRight(R seed, java.util.function.BiFunction<? super U,R,R> function)
scanRight in interface org.jooq.lambda.Seq<U>default EagerFutureStream<U> reverse()
reverse in interface org.jooq.lambda.Seq<U>default EagerFutureStream<U> shuffle()
shuffle in interface org.jooq.lambda.Seq<U>default EagerFutureStream<U> shuffle(java.util.Random random)
shuffle in interface org.jooq.lambda.Seq<U>default EagerFutureStream<U> skipWhile(java.util.function.Predicate<? super U> predicate)
skipWhile in interface org.jooq.lambda.Seq<U>Seq.skipWhile(Stream, Predicate)default EagerFutureStream<U> skipUntil(java.util.function.Predicate<? super U> predicate)
skipUntil in interface org.jooq.lambda.Seq<U>Seq.skipUntil(Stream, Predicate)default EagerFutureStream<U> limitWhile(java.util.function.Predicate<? super U> predicate)
limitWhile in interface org.jooq.lambda.Seq<U>Seq.limitWhile(Stream, Predicate)default EagerFutureStream<U> limitUntil(java.util.function.Predicate<? super U> predicate)
limitUntil in interface org.jooq.lambda.Seq<U>Seq.limitUntil(Stream, Predicate)default EagerFutureStream<U> intersperse(U value)
intersperse in interface FutureStream<U>intersperse in interface org.jooq.lambda.Seq<U>Seq.intersperse(Stream, Object)static <U> EagerFutureStream<U> parallel(U... array)
array - Values to react todefault EagerFutureStream<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<EagerFutureStream<U>,EagerFutureStream<U>> duplicateFutureStream()
duplicate()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)default org.jooq.lambda.tuple.Tuple2<EagerFutureStream<U>,EagerFutureStream<U>> partitionFutureStream(java.util.function.Predicate<? super U> predicate)
predicate - Predicate to split Streampartition(Predicate)default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> splitAt(long position)
splitAt in interface org.jooq.lambda.Seq<U>Seq.splitAt(Stream, long)default org.jooq.lambda.tuple.Tuple2<EagerFutureStream<U>,EagerFutureStream<U>> splitAtFutureStream(long position)
splitAt(long)default org.jooq.lambda.tuple.Tuple2<java.util.Optional<U>,org.jooq.lambda.Seq<U>> splitAtHead()
splitAtHead in interface org.jooq.lambda.Seq<U>Seq.splitAt(Stream, long)default org.jooq.lambda.tuple.Tuple2<java.util.Optional<U>,EagerFutureStream<U>> splitAtHeadFutureStream()
splitAtHead()static EagerReact parallelBuilder()
parallelBuilder in interface SimpleReactStream<U>SimpleReact.SimpleReact()static EagerReact parallelBuilder(int parallelism)
parallelBuilder in interface SimpleReactStream<U>parallelism - Number of threads task executor should havestatic EagerReact paraellelCommonBuilder()
see RetryBuilder#getDefaultInstance()static EagerReact sequentialBuilder()
sequentialBuilder in interface SimpleReactStream<U>static EagerReact sequentialCommonBuilder()
sequentialCommonBuilder in interface SimpleReactStream<U>static EagerReact eagerBuilder(java.util.concurrent.ExecutorService executor)
executor - Executor this EagerReact instance will use to execute
concurrent tasks.static EagerReact eagerBuilder(com.nurkiewicz.asyncretry.RetryExecutor retry)
retry - RetryExecutor this SimpleReact instance will use to retry
concurrent tasks.static EagerReact eagerBuilder(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> EagerFutureStream<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> EagerFutureStream<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> EagerFutureStream<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> EagerFutureStream<T> futureStream(java.util.stream.Stream<T> stream)
futureStream in interface SimpleReactStream<U>static <T> EagerFutureStream<T> futureStream(java.lang.Iterable<T> iterable)
futureStream in interface SimpleReactStream<U>static <T> EagerFutureStream<T> futureStream(java.util.Iterator<T> iterator)
futureStream in interface SimpleReactStream<U>