public final class PublisherFactory extends Object
Publisher
factory which callbacks on start, request and shutdown
The Publisher will directly forward all the signals passed to the subscribers and complete when onComplete is called.
Create such publisher with the provided factory, E.g.:
PublisherFactory.create((n, sub) -> {
for(int i = 0; i < n; i++){
sub.onNext(i);
}
}
Modifier and Type | Class and Description |
---|---|
static class |
PublisherFactory.PrematureCompleteException |
Constructor and Description |
---|
PublisherFactory() |
Modifier and Type | Method and Description |
---|---|
static <I,O> org.reactivestreams.Publisher<O> |
barrier(org.reactivestreams.Publisher<I> source,
BiConsumer<I,org.reactivestreams.Subscriber<? super O>> dataConsumer)
Intercept a source
Publisher onNext signal to eventually transform, forward or filter the data by calling
or not
the right operand Subscriber . |
static <I,O> org.reactivestreams.Publisher<O> |
barrier(org.reactivestreams.Publisher<I> source,
BiConsumer<I,org.reactivestreams.Subscriber<? super O>> dataConsumer,
BiConsumer<Throwable,org.reactivestreams.Subscriber<? super O>> errorConsumer)
Intercept a source
Publisher onNext signal to eventually transform, forward or filter the data by calling
or not
the right operand Subscriber . |
static <I,O> org.reactivestreams.Publisher<O> |
barrier(org.reactivestreams.Publisher<I> source,
BiConsumer<I,org.reactivestreams.Subscriber<? super O>> dataConsumer,
BiConsumer<Throwable,org.reactivestreams.Subscriber<? super O>> errorConsumer,
Consumer<org.reactivestreams.Subscriber<? super O>> completeConsumer)
Intercept a source
Publisher onNext signal to eventually transform, forward or filter the data by calling
or not
the right operand Subscriber . |
static <T,C> org.reactivestreams.Publisher<T> |
create(BiConsumer<Long,SubscriberWithContext<T,C>> requestConsumer,
Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory)
Create a
Publisher reacting on requests with the passed BiConsumer
The argument contextFactory is executed once by new subscriber to generate a context shared by every
request calls. |
static <T,C> org.reactivestreams.Publisher<T> |
create(BiConsumer<Long,SubscriberWithContext<T,C>> requestConsumer,
Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory,
Consumer<C> shutdownConsumer)
Create a
Publisher reacting on requests with the passed BiConsumer . |
static <T> org.reactivestreams.Publisher<T> |
create(BiConsumer<Long,SubscriberWithContext<T,Void>> requestConsumer)
Create a
Publisher reacting on requests with the passed BiConsumer |
static <T,C> org.reactivestreams.Publisher<T> |
forEach(Consumer<SubscriberWithContext<T,C>> requestConsumer,
Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory)
|
static <T,C> org.reactivestreams.Publisher<T> |
forEach(Consumer<SubscriberWithContext<T,C>> requestConsumer,
Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory,
Consumer<C> shutdownConsumer)
|
static <T> org.reactivestreams.Publisher<T> |
forEach(Consumer<SubscriberWithContext<T,Void>> requestConsumer)
|
static <I,O> org.reactivestreams.Publisher<O> |
intercept(org.reactivestreams.Publisher<? extends I> source,
Function<org.reactivestreams.Subscriber<? super O>,SubscriberBarrier<I,O>> barrierProvider)
Create a
Publisher intercepting all source signals with a SubscriberBarrier per Subscriber
provided by the given barrierProvider. |
public static <T> org.reactivestreams.Publisher<T> create(BiConsumer<Long,SubscriberWithContext<T,Void>> requestConsumer)
Publisher
reacting on requests with the passed BiConsumer
T
- The type of the data sequencerequestConsumer
- A BiConsumer
with left argument request and right argument target subscriberpublic static <T,C> org.reactivestreams.Publisher<T> create(BiConsumer<Long,SubscriberWithContext<T,C>> requestConsumer, Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory)
Publisher
reacting on requests with the passed BiConsumer
The argument contextFactory
is executed once by new subscriber to generate a context shared by every
request calls.T
- The type of the data sequenceC
- The type of contextual information to be read by the requestConsumerrequestConsumer
- A BiConsumer
with left argument request and right argument target subscribercontextFactory
- A Function
called for every new subscriber returning an immutable context (IO
connection...)public static <T,C> org.reactivestreams.Publisher<T> create(BiConsumer<Long,SubscriberWithContext<T,C>> requestConsumer, Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory, Consumer<C> shutdownConsumer)
Publisher
reacting on requests with the passed BiConsumer
.
The argument contextFactory
is executed once by new subscriber to generate a context shared by every
request calls.
The argument shutdownConsumer
is executed once by subscriber termination event (cancel, onComplete,
onError).T
- The type of the data sequenceC
- The type of contextual information to be read by the requestConsumerrequestConsumer
- A BiConsumer
with left argument request and right argument target subscribercontextFactory
- A Function
called once for every new subscriber returning an immutable context
(IO connection...)shutdownConsumer
- A Consumer
called once everytime a subscriber terminates: cancel, onComplete(),
onError()public static <T> org.reactivestreams.Publisher<T> forEach(Consumer<SubscriberWithContext<T,Void>> requestConsumer)
Publisher
reacting on each available Subscriber
read derived with the passed Consumer
. If a previous request is still running, avoid recursion and extend the previous request iterations.T
- The type of the data sequencerequestConsumer
- A Consumer
invoked when available read with the target subscriberpublic static <T,C> org.reactivestreams.Publisher<T> forEach(Consumer<SubscriberWithContext<T,C>> requestConsumer, Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory)
Publisher
reacting on each available Subscriber
read derived with the passed Consumer
. If a previous request is still running, avoid recursion and extend the previous request iterations.
The argument contextFactory
is executed once by new subscriber to generate a context shared by every
request calls.T
- The type of the data sequenceC
- The type of contextual information to be read by the requestConsumerrequestConsumer
- A Consumer
invoked when available read with the target subscribercontextFactory
- A Function
called for every new subscriber returning an immutable context (IO
connection...)public static <T,C> org.reactivestreams.Publisher<T> forEach(Consumer<SubscriberWithContext<T,C>> requestConsumer, Function<org.reactivestreams.Subscriber<? super T>,C> contextFactory, Consumer<C> shutdownConsumer)
Publisher
reacting on each available Subscriber
read derived with the passed Consumer
. If a previous request is still running, avoid recursion and extend the previous request iterations.
The argument contextFactory
is executed once by new subscriber to generate a context shared by every
request calls.
The argument shutdownConsumer
is executed once by subscriber termination event (cancel, onComplete,
onError).T
- The type of the data sequenceC
- The type of contextual information to be read by the requestConsumerrequestConsumer
- A Consumer
invoked when available read with the target subscribercontextFactory
- A Function
called once for every new subscriber returning an immutable context
(IO connection...)shutdownConsumer
- A Consumer
called once everytime a subscriber terminates: cancel, onComplete(),
onError()public static <I,O> org.reactivestreams.Publisher<O> barrier(org.reactivestreams.Publisher<I> source, BiConsumer<I,org.reactivestreams.Subscriber<? super O>> dataConsumer)
Publisher
onNext signal to eventually transform, forward or filter the data by calling
or not
the right operand Subscriber
.I
- The source type of the data sequenceO
- The target type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument output subscriberpublic static <I,O> org.reactivestreams.Publisher<O> barrier(org.reactivestreams.Publisher<I> source, BiConsumer<I,org.reactivestreams.Subscriber<? super O>> dataConsumer, BiConsumer<Throwable,org.reactivestreams.Subscriber<? super O>> errorConsumer)
Publisher
onNext signal to eventually transform, forward or filter the data by calling
or not
the right operand Subscriber
.I
- The source type of the data sequenceO
- The target type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument output subscribererrorConsumer
- A BiConsumer
with left argument onError throwable and right argument output subpublic static <I,O> org.reactivestreams.Publisher<O> barrier(org.reactivestreams.Publisher<I> source, BiConsumer<I,org.reactivestreams.Subscriber<? super O>> dataConsumer, BiConsumer<Throwable,org.reactivestreams.Subscriber<? super O>> errorConsumer, Consumer<org.reactivestreams.Subscriber<? super O>> completeConsumer)
Publisher
onNext signal to eventually transform, forward or filter the data by calling
or not
the right operand Subscriber
.
The argument subscriptionHandler
is executed once by new subscriber to generate a context shared by every
request calls.
I
- The source type of the data sequenceO
- The target type of the data sequencedataConsumer
- A BiConsumer
with left argument onNext data and right argument output subscribererrorConsumer
- A BiConsumer
with left argument onError throwable and right argument output subcompleteConsumer
- A Consumer
called onComplete with the actual output subscriberpublic static <I,O> org.reactivestreams.Publisher<O> intercept(org.reactivestreams.Publisher<? extends I> source, Function<org.reactivestreams.Subscriber<? super O>,SubscriberBarrier<I,O>> barrierProvider)
Publisher
intercepting all source signals with a SubscriberBarrier
per Subscriber
provided by the given barrierProvider.I
- The type of the data sequenceO
- The type of contextual information to be read by the requestConsumersource
- A Publisher
source delegatebarrierProvider
- A Function
called once for every new subscriber returning a unique SubscriberBarrier
Copyright © 2016. All rights reserved.