public class SimpleReact extends BaseSimpleReact
| Constructor and Description |
|---|
SimpleReact()
Construct a SimpleReact builder using standard thread pool.
|
SimpleReact(java.util.concurrent.ExecutorService executor) |
| Modifier and Type | Method and Description |
|---|---|
<U> SimpleReactStream<U> |
construct(java.util.stream.Stream s,
java.util.concurrent.ExecutorService executor,
com.nurkiewicz.asyncretry.RetryExecutor retrier,
boolean eager) |
<U> SimpleReactStream<U> |
fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
Start a reactive dataflow from a stream of CompletableFutures.
|
<U> SimpleReactStream<U> |
fromStreamWithoutFutures(java.util.stream.Stream<U> stream)
Start a reactive dataflow from a stream.
|
static <T> ReactIterator<T> |
iterate(T seed)
Create an iterator that manages a function call starting with the supplied seed value
|
<U> SimpleReactStream<U> |
iterateInfinitely(U seed,
java.util.function.UnaryOperator<U> f) |
<U> SimpleReactStream<U> |
of(U... array) |
<U> SimpleReactStream<U> |
react(java.util.function.Function<U,U> f,
ReactIterator<U> t)
Start a reactive dataflow that calls the supplied function iteratively, with each output, feeding into the next input
Example :-
List<Integer> results = new SimpleReact()
.<Integer> react((input) -> input + 1,iterate(0).times(1).offset(10))
|
<U> SimpleReactStream<U> |
react(java.util.Iterator<U> iterator,
int maxTimes)
Start a reactive flow from a JDK Iterator
|
<U> SimpleReactStream<U> |
react(java.util.List<java.util.function.Supplier<U>> actions)
Start a reactive dataflow with a list of one-off-suppliers
|
<U> SimpleReactStream<U> |
react(java.util.function.Supplier<U>... actions)
Start a reactive dataflow with an array of one-off-suppliers
|
<U> SimpleReactStream<U> |
react(java.util.function.Supplier<U> s,
Generator t)
Start a reactive dataflow from a single Supplier, which will be executed repeatedly according to rules defined by the generator.
|
protected <U> SimpleReactStream<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> SimpleReactStream<U> |
reactInfinitely(java.util.function.Supplier<U> s)
Generate an infinite reactive flow.
|
<R> SimpleReactStream<R> |
reactToCollection(java.util.Collection<R> collection)
Start a reactive flow from a Collection using an Iterator
|
static ParallelGenerator |
times(int times)
Create a Sequential Generator that will trigger a Supplier to be called the specified number of times
|
static ParallelGenerator |
timesInSequence(int times)
Create a Parallel Generator that will trigger a Supplier to be called the specified number of times
|
getExecutor, getRetrier, isEagerpublic SimpleReact()
ThreadPools.getStandard()public SimpleReact(java.util.concurrent.ExecutorService executor)
executor - Executor this SimpleReact instance will use to execute concurrent tasks.public <U> SimpleReactStream<U> construct(java.util.stream.Stream s, java.util.concurrent.ExecutorService executor, com.nurkiewicz.asyncretry.RetryExecutor retrier, boolean eager)
construct in class BaseSimpleReactpublic <U> SimpleReactStream<U> fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
fromStream in class BaseSimpleReactstream - of CompletableFutures that will be used to drive the reactive dataflowpublic <U> SimpleReactStream<U> fromStreamWithoutFutures(java.util.stream.Stream<U> stream)
fromStreamWithoutFutures in class BaseSimpleReactstream - that will be used to drive the reactive dataflowpublic <U> SimpleReactStream<U> of(U... array)
of in class BaseSimpleReactpublic <U> SimpleReactStream<U> react(java.util.List<java.util.function.Supplier<U>> actions)
react in class BaseSimpleReactactions - List of Suppliers to provide data (and thus events) that
downstream jobs will react toopublic <U> SimpleReactStream<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> SimpleReactStream<R> reactToCollection(java.util.Collection<R> collection)
reactToCollection in class BaseSimpleReactcollection - - Collection SimpleReact will iterate over at the start of the flowpublic <U> SimpleReactStream<U> react(java.util.function.Supplier<U> s, Generator t)
List<String> strings = new SimpleReact()
.<Integer> react(() -> count++ ,SimpleReact.times(4))
To skip the first 5 iterations and take the next 5
*
List<String> strings = new SimpleReact()
.<Integer> react(() -> count++ ,SimpleReact.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> SimpleReactStream<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> SimpleReactStream<U> iterateInfinitely(U seed, java.util.function.UnaryOperator<U> f)
iterateInfinitely in class BaseSimpleReactpublic static ParallelGenerator times(int times)
times - Number of times the Supplier should be called at the start of the reactive dataflowpublic static ParallelGenerator timesInSequence(int times)
times - Number of times the Supplier should be called at the start of the reactive dataflowpublic <U> SimpleReactStream<U> react(java.util.function.Function<U,U> f, ReactIterator<U> t)
List<Integer> results = new SimpleReact()
.<Integer> react((input) -> input + 1,iterate(0).times(1).offset(10))
react in class BaseSimpleReactf - Function to be called iterativelyt - Iterator that manages function callpublic static <T> ReactIterator<T> iterate(T seed)
seed - Initial value that iterator will apply to the function it iterates over@SafeVarargs public final <U> SimpleReactStream<U> react(java.util.function.Supplier<U>... actions)
react in class BaseSimpleReactactions - Array of Suppliers to provide data (and thus events) that
downstream jobs will react tooprotected <U> SimpleReactStream<U> reactI(java.util.function.Supplier<U>... actions)
reactI in class BaseSimpleReact