public class SimpleReact
extends java.lang.Object
implements com.aol.cyclops2.internal.react.stream.ReactBuilder
new SimpleReact().react(this:query,this:query,this:query,this:query)
.transform(this:process)
.block(status -> status.getAllCompleted() >2 && status.getElapsedMillis()>200);
//short circuit if 2 results after 200ms
E.g. loading files
List<File> files;
new SimpleReact().from(files)
.thenAsync(FileUtils::load)
.transform(this:process)
.block();
In general if you have a small discrete data sets SimpleReact may be a fit.
If you need infinite / continuous Stream processing & more advanced features use LazyReact
(Even flatMap is relatively limited in SimpleReact Stream - for advanced operations @see LazyReact)Constructor and Description |
---|
SimpleReact()
Construct a SimpleReact builder using standard thread pool.
|
SimpleReact(java.util.concurrent.Executor executor)
Construct a SimpleReact builder from the provided Executor
|
SimpleReact(java.util.concurrent.Executor executor,
java.lang.Boolean async)
Construct a SimpleReact builder from the provided Executor, Retrier.
|
SimpleReact(java.util.concurrent.Executor executor,
java.util.concurrent.Executor queueCopier) |
SimpleReact(java.util.concurrent.Executor queueService,
java.util.concurrent.Executor executor,
java.lang.Boolean async) |
Modifier and Type | Method and Description |
---|---|
<U> SimpleReactStream<U> |
construct(java.util.stream.Stream s) |
<R> SimpleReactStream<R> |
from(java.util.Collection<R> collection)
Start a reactiveBuffer flow from a Collection using an Iterator
|
<U> SimpleReactStream<U> |
from(java.util.concurrent.CompletableFuture<U>... cf)
Construct a simpleReactStream from an Array of CompletableFutures
|
<U> SimpleReactStream<U> |
from(java.util.concurrent.CompletableFuture<U> cf) |
<U> SimpleReactStream<java.lang.Double> |
from(java.util.stream.DoubleStream stream)
Start a reactiveBuffer dataflow from a reactiveStream.
|
<U> SimpleReactStream<java.lang.Integer> |
from(java.util.stream.IntStream stream)
Start a reactiveBuffer dataflow from a reactiveStream.
|
<U> SimpleReactStream<U> |
from(java.util.Iterator<U> iterator)
Start a reactiveBuffer flow from a JDK Iterator
|
<U> SimpleReactStream<java.lang.Long> |
from(java.util.stream.LongStream stream)
Start a reactiveBuffer dataflow from a reactiveStream.
|
<U> SimpleReactStream<U> |
from(java.util.stream.Stream<U> stream)
Start a reactiveBuffer dataflow from a reactiveStream.
|
<U> SimpleReactStream<U> |
fromIterable(java.lang.Iterable<U> iter)
Start a reactiveBuffer flow from a JDK Iterator
|
<U> SimpleReactStream<U> |
fromIterableAsync(java.lang.Iterable<? extends java.util.function.Supplier<U>> actions)
Start a reactiveBuffer dataflow with a list of one-off-suppliers
|
<U> SimpleReactStream<U> |
fromIteratorAsync(java.util.Iterator<? extends java.util.function.Supplier<U>> actions)
Start a reactiveBuffer dataflow with a list of one-off-suppliers
|
<T> SimpleReactStream<T> |
fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
Construct a SimpleReactStream from an Publisher
|
<U> SimpleReactStream<U> |
fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
Start a reactiveBuffer dataflow from a reactiveStream of CompletableFutures.
|
<U> SimpleReactStream<U> |
fromStreamAsync(java.util.stream.Stream<? extends java.util.function.Supplier<U>> actions)
Start a reactiveBuffer dataflow with a list of one-off-suppliers
|
boolean |
isAsync() |
<U> SimpleReactStream<U> |
of(U... array) |
<U> SimpleReactStream<U> |
ofAsync(java.util.function.Supplier<U>... actions)
Start a reactiveBuffer dataflow with an array of one-off-suppliers
|
static SimpleReact |
parallelBuilder() |
static SimpleReact |
parallelBuilder(int parallelism)
Construct a new SimpleReact builder, with a new task executor and retry executor
with configured number of threads
|
static SimpleReact |
parallelCommonBuilder() |
SimpleReactStream<java.lang.Integer> |
range(int startInclusive,
int endExclusive) |
static SimpleReact |
sequentialBuilder() |
static SimpleReact |
sequentialCommonBuilder() |
SimpleReact |
withQueueCopyExecutor(java.util.concurrent.Executor queueCopyExecutor) |
public SimpleReact()
ThreadPools.getStandard()
public SimpleReact(java.util.concurrent.Executor executor, java.lang.Boolean async)
executor
- Task executor to execute tasks onretrier
- Retrier to use for asyncrhonous retryasync
- If false, subsequent tasks are executed on the completing thread
If true each subsequent task is resubmitted to a task executor,public SimpleReact(java.util.concurrent.Executor executor)
executor
- Task executor to execute tasks onpublic SimpleReact(java.util.concurrent.Executor executor, java.util.concurrent.Executor queueCopier)
executor
- Task executor to execute tasks onretrier
- queueCopier
- Task executor to transfer results during flatMap operationspublic SimpleReact(java.util.concurrent.Executor queueService, java.util.concurrent.Executor executor, java.lang.Boolean async)
public <U> SimpleReactStream<U> construct(java.util.stream.Stream s)
public SimpleReact withQueueCopyExecutor(java.util.concurrent.Executor queueCopyExecutor)
public <U> SimpleReactStream<U> fromStreamAsync(java.util.stream.Stream<? extends java.util.function.Supplier<U>> actions)
actions
- Stream of Suppliers to provide data (and thus events) that
downstream jobs will react toopublic <T> SimpleReactStream<T> fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
publisher
- to construct SimpleReactStream frompublic <U> SimpleReactStream<U> fromIteratorAsync(java.util.Iterator<? extends java.util.function.Supplier<U>> actions)
actions
- Iterator over Suppliers to provide data (and thus events) that
downstream jobs will react toopublic <U> SimpleReactStream<U> fromIterableAsync(java.lang.Iterable<? extends java.util.function.Supplier<U>> actions)
actions
- Stream of Suppliers to provide data (and thus events) that
downstream jobs will react too@SafeVarargs public final <U> SimpleReactStream<U> ofAsync(java.util.function.Supplier<U>... actions)
actions
- Array of Suppliers to provide data (and thus events) that
downstream jobs will react toopublic <U> SimpleReactStream<U> from(java.util.stream.Stream<U> stream)
stream
- that will be used to drive the reactiveBuffer dataflowpublic <R> SimpleReactStream<R> from(java.util.Collection<R> collection)
collection
- - Collection SimpleReact will iterate over at the skip of the flowpublic boolean isAsync()
public static SimpleReact parallelBuilder()
SimpleReact()
public static SimpleReact parallelBuilder(int parallelism)
parallelism
- Number of threads task executor should havepublic static SimpleReact parallelCommonBuilder()
see RetryBuilder#getDefaultInstance()
public static SimpleReact sequentialBuilder()
public static SimpleReact sequentialCommonBuilder()
public SimpleReactStream<java.lang.Integer> range(int startInclusive, int endExclusive)
public <U> SimpleReactStream<U> from(java.util.Iterator<U> iterator)
iterator
- SimpleReact will iterate over this iterator concurrently to skip the reactiveBuffer dataflowpublic <U> SimpleReactStream<U> fromIterable(java.lang.Iterable<U> iter)
iter
- SimpleReact will iterate over this iterator concurrently to skip the reactiveBuffer dataflowpublic <U> SimpleReactStream<U> fromStream(java.util.stream.Stream<java.util.concurrent.CompletableFuture<U>> stream)
stream
- of CompletableFutures that will be used to drive the reactiveBuffer dataflowpublic <U> SimpleReactStream<java.lang.Integer> from(java.util.stream.IntStream stream)
stream
- that will be used to drive the reactiveBuffer dataflowpublic <U> SimpleReactStream<java.lang.Double> from(java.util.stream.DoubleStream stream)
stream
- that will be used to drive the reactiveBuffer dataflowpublic <U> SimpleReactStream<java.lang.Long> from(java.util.stream.LongStream stream)
stream
- that will be used to drive the reactiveBuffer dataflowpublic <U> SimpleReactStream<U> of(U... array)
public <U> SimpleReactStream<U> from(java.util.concurrent.CompletableFuture<U> cf)
public <U> SimpleReactStream<U> from(java.util.concurrent.CompletableFuture<U>... cf)
cf
- CompletableFutures to turn into a Stream