public static interface Sinks.One<T> extends Sinks.Empty<T>
Sinks with Mono semantics.
The sink can be exposed to consuming code as a Mono via its Sinks.Empty.asMono() view.
Scannable.Attr<T>OPERATOR_NAME_UNRELATED_WORDS_PATTERN| Modifier and Type | Method and Description |
|---|---|
void |
emitValue(T value,
Sinks.EmitFailureHandler failureHandler)
A simplified attempt at emitting a non-null element via the
tryEmitValue(Object) API, generating an
onNext signal immediately followed by an Subscriber.onComplete() signal. |
Sinks.EmitResult |
tryEmitValue(T value)
Try to complete the
Mono with an element, generating an onNext signal
immediately followed by an onComplete signal. |
asMono, currentSubscriberCount, emitEmpty, emitError, tryEmitEmpty, tryEmitErroractuals, from, inners, isScanAvailable, name, parents, scan, scanOrDefault, scanUnsafe, stepName, steps, tags, tagsDeduplicatedSinks.EmitResult tryEmitValue(@Nullable T value)
Mono with an element, generating an onNext signal
immediately followed by an onComplete signal. A null value
will only trigger the onComplete. The result of the attempt is represented as an Sinks.EmitResult,
which possibly indicates error cases.
See the list of failure Sinks.EmitResult in #emitValue(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, ...).
value - the value to emit and complete with, or null to only trigger an onCompleteSinks.EmitResult, which should be checked to distinguish different possible failuresemitValue(Object, Sinks.EmitFailureHandler),
Subscriber.onNext(Object),
Subscriber.onComplete()void emitValue(@Nullable T value, Sinks.EmitFailureHandler failureHandler)
tryEmitValue(Object) API, generating an
onNext signal immediately followed by an Subscriber.onComplete() signal.
If the result of the attempt is not a success, implementations SHOULD retry the
tryEmitValue(Object) call IF the provided Sinks.EmitFailureHandler returns true.
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 returned Sinks.EmitResult and correctly
acting on it. This API is intended as a good default for convenience.
When the Sinks.EmitResult is 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 no Subscriber from which to get a contextual discard handler.
Sinks.EmitResult.FAIL_OVERFLOW: discard the value (Operators.onDiscard(Object, Context))
then call Sinks.Empty.emitError(Throwable, Sinks.EmitFailureHandler) with a Exceptions.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 an Sinks.EmissionException mentioning RS spec rule 1.3.
Note that Sinks.unsafe() never trigger this result. It would be possible for an Sinks.EmitFailureHandler
to 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_SERIALIZED
as described above, ...).
value - the value to emit and complete with, a null is actually acceptable to only trigger an onCompletefailureHandler - the failure handler that allows retrying failed Sinks.EmitResult.Sinks.EmissionException - on non-serialized accesstryEmitValue(Object),
Subscriber.onNext(Object),
Subscriber.onComplete()