Interface FluxSink<T>
- Type Parameters:
T- the value type
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumEnumeration for backpressure handling. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Terminate the sequence successfully, generating anonCompletesignal.default ContextViewReturn the current subscriber's context as aContextViewfor inspection.Deprecated.To be removed in 3.6.0 at the earliest.voidFail the sequence, generating anonErrorsignal.booleanReturns true if the downstream cancelled the sequence.Emit a non-null element, generating anonNextsignal.Attach aDisposableas a callback for when thisFluxSinkis cancelled.Attach aDisposableas a callback for when thisFluxSinkis effectively disposed, that is it cannot be used anymore.onRequest(LongConsumer consumer) Attaches aLongConsumerto thisFluxSinkthat will be notified of any request to this sink.longThe current outstanding request amount.
-
Method Details
-
next
Emit a non-null element, generating anonNextsignal.Might throw an unchecked exception in case of a fatal error downstream which cannot be propagated to any asynchronous handler (aka a bubbling exception).
- Parameters:
t- the value to emit, not null- Returns:
- this sink for chaining further signals
-
complete
void complete()Terminate the sequence successfully, generating anonCompletesignal.- See Also:
-
error
Fail the sequence, generating anonErrorsignal.- Parameters:
e- the exception to signal, not null- See Also:
-
currentContext
Deprecated.To be removed in 3.6.0 at the earliest. Prefer using #contextView() instead.Return the current subscriberContext.Contextcan be enriched viaFlux.contextWrite(Function)operator or directly by a child subscriber overridingCoreSubscriber.currentContext() -
contextView
Return the current subscriber's context as aContextViewfor inspection.Contextcan be enriched downstream viaFlux.contextWrite(Function)operator or directly by a child subscriber overridingCoreSubscriber.currentContext().- Returns:
- the current subscriber
ContextView.
-
requestedFromDownstream
long requestedFromDownstream()The current outstanding request amount.- Returns:
- the current outstanding request amount
-
isCancelled
boolean isCancelled()Returns true if the downstream cancelled the sequence.- Returns:
- true if the downstream cancelled the sequence
-
onRequest
Attaches aLongConsumerto thisFluxSinkthat will be notified of any request to this sink.For push/pull sinks created using
Flux.create(java.util.function.Consumer)orFlux.create(java.util.function.Consumer, FluxSink.OverflowStrategy), the consumer is invoked for every request to enable a hybrid backpressure-enabled push/pull model.Note: in case of multiple
Subscription.request(long)happening concurrently to this method, the first consumer invocation may process accumulated demand instead of being called multiple times.When bridging with asynchronous listener-based APIs, the
onRequestcallback 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)orFlux.push(java.util.function.Consumer, FluxSink.OverflowStrategy), the consumer is invoked with an initial request ofLong.MAX_VALUEwhen this method is invoked.- Parameters:
consumer- the consumer to invoke on each request- Returns:
FluxSinkwith a consumer that is notified of requests
-
onCancel
Attach aDisposableas a callback for when thisFluxSinkis cancelled. At most one callback can be registered, and subsequent calls to this method will result in the immediate disposal of the extraneousDisposable.The callback is only relevant when the downstream
Subscriptioniscancelled.- Parameters:
d- theDisposableto use as a callback- Returns:
- the
FluxSinkwith a cancellation callback - See Also:
-
onDispose
Attach aDisposableas a callback for when thisFluxSinkis effectively disposed, that is it cannot be used anymore. This includes both having played terminal signals (onComplete, onError) and having been cancelled (seeonCancel(Disposable)). At most one callback can be registered, and subsequent calls to this method will result in the immediate disposal of the extraneousDisposable.Note that the "dispose" term is used from the perspective of the sink. Not to be confused with
Flux.subscribe()'sDisposable.dispose()method, which maps to disposing theSubscription(effectively, aSubscription.cancel()signal).- Parameters:
d- theDisposableto use as a callback- Returns:
- the
FluxSinkwith a callback invoked on any terminal signal or on cancellation - See Also:
-