public class LazyReact extends BaseSimpleReact
| Constructor and Description |
|---|
LazyReact()
Construct a LazyReact builder using standard thread pool.
|
LazyReact(java.util.concurrent.ExecutorService executor)
Construct a LazyReact builder with provided ExecutorService
|
| Modifier and Type | Method and Description |
|---|---|
<U> LazyFutureStream<U> |
construct(java.util.stream.Stream s,
java.util.concurrent.ExecutorService executor,
com.nurkiewicz.asyncretry.RetryExecutor retrier,
boolean eager) |
<U> LazyFutureStream<U> |
fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
Start a reactive dataflow from a stream of CompletableFutures.
|
<U> LazyFutureStream<U> |
fromStreamWithoutFutures(java.util.stream.Stream<U> stream)
Start a reactive dataflow from a stream.
|
<U> LazyFutureStream<U> |
iterateInfinitely(U seed,
java.util.function.UnaryOperator<U> f) |
<U> LazyFutureStream<U> |
of(U... array) |
<U> LazyFutureStream<U> |
react(java.util.function.Function<U,U> f,
ReactIterator<U> t)
Start a LazyFutureStream that calls the supplied function iteratively, with each output, feeding into the next input
Example :-
List<Integer> results = new LazyReact()
.<Integer> react((input) -> input + 1,iterate(0).times(1).offset(10))
|
<U> LazyFutureStream<U> |
react(java.util.Iterator<U> iterator,
int maxTimes)
Start a LazyFutureStream from a JDK Iterator
|
<U> LazyFutureStream<U> |
react(java.util.List<java.util.function.Supplier<U>> actions)
Start a reactive dataflow with a list of one-off-suppliers
|
<U> LazyFutureStream<U> |
react(java.util.function.Supplier<U> s,
Generator t)
Start a LazyFutureStream from a single Supplier, which will be executed repeatedly according to rules defined by the generator.
|
protected <U> LazyFutureStream<U> |
reactI(java.util.function.Supplier<U>... actions)
This internal method has been left protected, so it can be mocked / stubbed as some of the entry points are final
|
<U> LazyFutureStream<U> |
reactInfinitely(java.util.function.Supplier<U> s)
Generate an infinite LazyFutureStream
The flow will run indefinitely unless / until the provided Supplier throws an Exception
|
<R> LazyFutureStream<R> |
reactToCollection(java.util.Collection<R> collection)
Start a LazyFutureStream from a Collection
|
getExecutor, getRetrier, isEager, iterate, react, times, timesInSequencepublic LazyReact()
ThreadPools.getStandard()public LazyReact(java.util.concurrent.ExecutorService executor)
executor - ExecutorService to usepublic <U> LazyFutureStream<U> construct(java.util.stream.Stream s, java.util.concurrent.ExecutorService executor, com.nurkiewicz.asyncretry.RetryExecutor retrier, boolean eager)
construct in class BaseSimpleReactpublic <U> LazyFutureStream<U> fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
BaseSimpleReactfromStream in class BaseSimpleReactstream - of CompletableFutures that will be used to drive the reactive dataflowpublic <U> LazyFutureStream<U> fromStreamWithoutFutures(java.util.stream.Stream<U> stream)
BaseSimpleReactfromStreamWithoutFutures in class BaseSimpleReactstream - that will be used to drive the reactive dataflowpublic <U> LazyFutureStream<U> of(U... array)
of in class BaseSimpleReactpublic <U> LazyFutureStream<U> react(java.util.List<java.util.function.Supplier<U>> actions)
BaseSimpleReactreact in class BaseSimpleReactactions - List of Suppliers to provide data (and thus events) that
downstream jobs will react toopublic <U> LazyFutureStream<U> react(java.util.Iterator<U> iterator, int maxTimes)
react in class BaseSimpleReactiterator - SimpleReact will iterate over this iterator concurrently to start the reactive dataflowmaxTimes - Maximum number of iterationspublic <R> LazyFutureStream<R> reactToCollection(java.util.Collection<R> collection)
reactToCollection in class BaseSimpleReactcollection - - Collection Stream will be formed frompublic <U> LazyFutureStream<U> react(java.util.function.Supplier<U> s, Generator t)
List<String> strings = new LazyReact()
.<Integer> react(() -> count++ ,LazyReact.times(4))
To skip the first 5 iterations and take the next 5
*
List<String> strings = new LazyReact()
.<Integer> react(() -> count++ ,LazyReact.times(5).offset(5))
The supplier will be called 10 times, in the above example, but only the last 5 results will be passed into the
reactive dataflow.react in class BaseSimpleReacts - Supplier to provide data (and thus events) that
downstream jobs will react toot - Generator implementation that will determine how the Supplier is executedpublic <U> LazyFutureStream<U> reactInfinitely(java.util.function.Supplier<U> s)
reactInfinitely in class BaseSimpleReacts - Supplier to generate the infinite flowSimpleReact Queue for a way to create a more managable infinit flowpublic <U> LazyFutureStream<U> iterateInfinitely(U seed, java.util.function.UnaryOperator<U> f)
iterateInfinitely in class BaseSimpleReactpublic <U> LazyFutureStream<U> react(java.util.function.Function<U,U> f, ReactIterator<U> t)
List<Integer> results = new LazyReact()
.<Integer> react((input) -> input + 1,iterate(0).times(1).offset(10))
react in class BaseSimpleReactf - Function to be called iterativelyt - Iterator that manages function callprotected <U> LazyFutureStream<U> reactI(java.util.function.Supplier<U>... actions)
BaseSimpleReactreactI in class BaseSimpleReact