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()
Terminate the sequence successfully, generating an
onComplete
signal. |
default ContextView |
contextView()
Return the current subscriber's context as a
ContextView for inspection. |
Context |
currentContext()
Deprecated.
To be removed in 3.6.0 at the earliest. Prefer using #contextView() instead.
|
void |
error(Throwable e)
Fail the sequence, generating an
onError
signal. |
boolean |
isCancelled()
Returns true if the downstream cancelled the sequence.
|
FluxSink<T> |
next(T t)
Emit a non-null element, generating an
onNext signal. |
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.
|
FluxSink<T> next(T t)
onNext
signal.
Might throw an unchecked exception in case of a fatal error downstream which cannot be propagated to any asynchronous handler (aka a bubbling exception).
t
- the value to emit, not nullvoid complete()
onComplete
signal.Subscriber.onComplete()
void error(Throwable e)
onError
signal.e
- the exception to signal, not nullSubscriber.onError(Throwable)
@Deprecated Context currentContext()
Context
.
Context
can be enriched via Flux.contextWrite(Function)
operator or directly by a child subscriber overriding
CoreSubscriber.currentContext()
default ContextView contextView()
ContextView
for inspection.
Context
can be enriched downstream via Flux.contextWrite(Function)
operator or directly by a child subscriber overriding CoreSubscriber.currentContext()
.
ContextView
.long requestedFromDownstream()
boolean isCancelled()
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 requestsFluxSink<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