Package org.opends.server.protocols
Class BlockingBackpressureOperator<T>
- java.lang.Object
-
- org.opends.server.protocols.BlockingBackpressureOperator<T>
-
- Type Parameters:
T
- Type of data processed by theFlowable
- All Implemented Interfaces:
FlowableOperator<T,T>
public final class BlockingBackpressureOperator<T> extends Object implements FlowableOperator<T,T>
Allows to connect a non back-pressure awarePublisher
into a reactive stream. This is needed to interface callback-based legacy code with back-pressure aware reactive-code.To prevent overflow when a non back-pressure aware publisher emits items which have not requested by the subscriber, the wrapped
Subscriber
will be blocked before propagating theonNext()
invocation. To do so, eachSubscriber
is wrapped into aBlockingBackpressureOperator.BlockingSubscriberWrapper
which will block theonNext()
caller until theSubscriber
is ready to receive the item (Subscription.request(long)
).
-
-
Constructor Summary
Constructors Constructor Description BlockingBackpressureOperator(Duration timeout, Supplier<Exception> timeoutExceptionSupplier)
Creates a new operator allowing to plug non back-pressure awarePublisher
to aFlowable
chain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactivestreams.Subscriber<? super T>
apply(org.reactivestreams.Subscriber<? super T> subscriber)
-
-
-
Constructor Detail
-
BlockingBackpressureOperator
public BlockingBackpressureOperator(Duration timeout, Supplier<Exception> timeoutExceptionSupplier)
Creates a new operator allowing to plug non back-pressure awarePublisher
to aFlowable
chain. The transformer will block the emitter thread waiting until whether the receiver is ready to process the item or the provided time-out expires in which caseTimeoutException
will be propagated through onError().- Parameters:
timeout
- Duration this transformer will wait for the receiver to be ready.timeoutExceptionSupplier
- supplier that will generate the exception to signal a timeout
-
-