T
- the value typepublic interface FluxSink<T>
Modifier and Type | Interface and Description |
---|---|
static class |
FluxSink.OverflowStrategy
Enumeration for backpressure handling.
|
Modifier and Type | Method and Description |
---|---|
void |
complete() |
Context |
currentContext()
Return the current subscriber
Context . |
void |
error(Throwable e) |
boolean |
isCancelled()
Returns true if the downstream cancelled the sequence.
|
FluxSink<T> |
next(T t)
Try emitting, might throw an unchecked exception.
|
FluxSink<T> |
onCancel(Disposable d)
Attach a
Disposable as a callback for when this FluxSink is
cancelled. |
FluxSink<T> |
onDispose(Disposable d)
Attach a
Disposable as a callback for when this FluxSink is effectively
disposed, that is it cannot be used anymore. |
FluxSink<T> |
onRequest(LongConsumer consumer)
Attaches a
LongConsumer to this FluxSink that will be notified of
any request to this sink. |
long |
requestedFromDownstream()
The current outstanding request amount.
|
void complete()
Subscriber.onComplete()
Context currentContext()
Context
.
Context
can be enriched via Flux.subscriberContext(Function)
operator or directly by a child subscriber overriding
CoreSubscriber.currentContext()
Context
.void error(Throwable e)
e
- the exception to signal, not nullSubscriber.onError(Throwable)
boolean isCancelled()
FluxSink<T> next(T t)
t
- the value to emit, not nullSubscriber.onNext(Object)
FluxSink<T> onCancel(Disposable d)
Disposable
as a callback for when this FluxSink
is
cancelled. At most one callback can be registered, and subsequent calls to this method
will result in the immediate disposal of the extraneous Disposable
.
The callback is only relevant when the downstream Subscription
is cancelled
.
d
- the Disposable
to use as a callbackFluxSink
with a cancellation callbackonDispose(Disposable) for a callback that covers cancellation AND terminal signals
FluxSink<T> onDispose(Disposable d)
Disposable
as a callback for when this FluxSink
is effectively
disposed, that is it cannot be used anymore. This includes both having played terminal
signals (onComplete, onError) and having been cancelled (see onCancel(Disposable)
).
At most one callback can be registered, and subsequent calls to this method will result in
the immediate disposal of the extraneous Disposable
.
Note that the "dispose" term is used from the perspective of the sink. Not to
be confused with Flux.subscribe()
's Disposable.dispose()
method, which
maps to disposing the Subscription
(effectively, a Subscription.cancel()
signal).
d
- the Disposable
to use as a callbackFluxSink
with a callback invoked on any terminal signal or on cancellationonCancel(Disposable) for a cancellation-only callback
FluxSink<T> onRequest(LongConsumer consumer)
LongConsumer
to this FluxSink
that will be notified of
any request to this sink.
For push/pull sinks created using Flux.create(java.util.function.Consumer)
or Flux.create(java.util.function.Consumer, FluxSink.OverflowStrategy)
,
the consumer
is invoked for every request to enable a hybrid backpressure-enabled push/pull model.
When bridging with asynchronous listener-based APIs, the onRequest
callback
may be used to request more data from source if required and to manage backpressure
by delivering data to sink only when requests are pending.
For push-only sinks created using Flux.push(java.util.function.Consumer)
or Flux.push(java.util.function.Consumer, FluxSink.OverflowStrategy)
,
the consumer is invoked with an initial request of Long.MAX_VALUE
when this method
is invoked.
consumer
- the consumer to invoke on each requestFluxSink
with a consumer that is notified of requestslong requestedFromDownstream()