Interface Sinks.One<T>
- All Superinterfaces:
Scannable,Sinks.Empty<T>
- All Known Implementing Classes:
SinkOneSerialized
- Enclosing class:
- Sinks
Sinks with Mono semantics.
The sink can be exposed to consuming code as a Mono via its Sinks.Empty.asMono() view.
- Author:
- Simon Baslé, Stephane Maldini
-
Nested Class Summary
Nested classes/interfaces inherited from interface reactor.core.Scannable
Scannable.Attr<T> -
Field Summary
Fields inherited from interface reactor.core.Scannable
OPERATOR_NAME_UNRELATED_WORDS_PATTERN -
Method Summary
Modifier and TypeMethodDescriptionvoidemitValue(@Nullable T value, Sinks.EmitFailureHandler failureHandler) A simplified attempt at emitting a non-null element via thetryEmitValue(Object)API, generating anonNextsignal immediately followed by anSubscriber.onComplete()signal.tryEmitValue(@Nullable T value) Try to complete theMonowith an element, generating anonNextsignal immediately followed by anonCompletesignal.Methods inherited from interface reactor.core.Scannable
actuals, inners, isScanAvailable, name, parents, scan, scanOrDefault, scanUnsafe, stepName, steps, tags, tagsDeduplicatedMethods inherited from interface reactor.core.publisher.Sinks.Empty
asMono, currentSubscriberCount, emitEmpty, emitError, tryEmitEmpty, tryEmitError
-
Method Details
-
tryEmitValue
Try to complete theMonowith an element, generating anonNextsignal immediately followed by anonCompletesignal. Anullvalue will only trigger the onComplete. The result of the attempt is represented as anSinks.EmitResult, which possibly indicates error cases.See the list of failure
Sinks.EmitResultinemitValue(Object, EmitFailureHandler)javadoc for an example of how each of these can be dealt with, to decide if the emit API would be a good enough fit instead.Might throw an unchecked exception as a last resort (eg. in case of a fatal error downstream which cannot be propagated to any asynchronous handler, a bubbling exception, ...).
- Parameters:
value- the value to emit and complete with, ornullto only trigger an onComplete- Returns:
- an
Sinks.EmitResult, which should be checked to distinguish different possible failures - See Also:
-
emitValue
A simplified attempt at emitting a non-null element via thetryEmitValue(Object)API, generating anonNextsignal immediately followed by anSubscriber.onComplete()signal. If the result of the attempt is not asuccess, implementations SHOULD retry thetryEmitValue(Object)call IF the providedSinks.EmitFailureHandlerreturnstrue. Otherwise, failures are dealt with in a predefined way that might depend on the actual sink implementation (see below for the vanilla reactor-core behavior).Generally,
tryEmitValue(Object)is preferable since it allows a custom handling of error cases, although this implies checking the returnedSinks.EmitResultand correctly acting on it. This API is intended as a good default for convenience.When the
Sinks.EmitResultis not a success, vanilla reactor-core operators have the following behavior:-
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER: no particular handling. should ideally discard the value but at that point there's noSubscriberfrom which to get a contextual discard handler. -
Sinks.EmitResult.FAIL_OVERFLOW: discard the value (Operators.onDiscard(Object, Context)) then callSinks.Empty.emitError(Throwable, Sinks.EmitFailureHandler)with aExceptions.failWithOverflow(String)exception. -
Sinks.EmitResult.FAIL_CANCELLED: discard the value (Operators.onDiscard(Object, Context)). -
Sinks.EmitResult.FAIL_TERMINATED: drop the value (Operators.onNextDropped(Object, Context)). -
Sinks.EmitResult.FAIL_NON_SERIALIZED: throw anSinks.EmissionExceptionmentioning RS spec rule 1.3. Note thatSinks.unsafe()never trigger this result. It would be possible for anSinks.EmitFailureHandlerto busy-loop and optimistically wait for the contention to disappear to avoid this case for safe sinks...
Might throw an unchecked exception as a last resort (eg. in case of a fatal error downstream which cannot be propagated to any asynchronous handler, a bubbling exception, a
Sinks.EmitResult.FAIL_NON_SERIALIZEDas described above, ...).- Parameters:
value- the value to emit and complete with, anullis actually acceptable to only trigger an onCompletefailureHandler- the failure handler that allows retrying failedSinks.EmitResult.- Throws:
Sinks.EmissionException- on non-serialized access- See Also:
-
-