Class SinkOneSerialized<T>
- All Implemented Interfaces:
Sinks.Empty<T>,Sinks.One<T>,Scannable
-
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 -
Constructor Summary
ConstructorsConstructorDescriptionSinkOneSerialized(Sinks.One<T> sinkOne, reactor.core.publisher.ContextHolder contextHolder) -
Method Summary
Modifier and TypeMethodDescriptionasMono()Return aMonoview of this sink.Request aContextfrom dependent components which can include downstream operators during subscribing or a terminalSubscriber.intGet how manySubscribersare currently subscribed to the sink.default voidemitEmpty(Sinks.EmitFailureHandler failureHandler) A simplified attempt at completing via theSinks.Empty.tryEmitEmpty()API, generating anonCompletesignal.default voidemitError(Throwable error, Sinks.EmitFailureHandler failureHandler) A simplified attempt at failing the sequence via theSinks.Empty.tryEmitError(Throwable)API, generating anonErrorsignal.default voidemitValue(T value, Sinks.EmitFailureHandler failureHandler) A simplified attempt at emitting a non-null element via theSinks.One.tryEmitValue(Object)API, generating anonNextsignal immediately followed by anSubscriber.onComplete()signal.inners()Return aStreamof referenced inners (flatmap, multicast etc)scanUnsafe(Scannable.Attr key) This method is used internally by components to define their key-value mappings in a single place.final Sinks.EmitResultTry to complete theMonowithout a value, generating only anonCompletesignal.final Sinks.EmitResultTry to complete theMonowith an element, generating anonNextsignal immediately followed by anonCompletesignal.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, tryEmitEmpty, tryEmitError
-
Constructor Details
-
SinkOneSerialized
-
-
Method Details
-
tryEmitValue
Description copied from interface:Sinks.OneTry 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.EmitResultinSinks.One.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, ...).
- Specified by:
tryEmitValuein interfaceSinks.One<T>- Parameters:
t- 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
Description copied from interface:Sinks.OneA simplified attempt at emitting a non-null element via theSinks.One.tryEmitValue(Object)API, generating anonNextsignal immediately followed by anSubscriber.onComplete()signal. If the result of the attempt is not asuccess, implementations SHOULD retry theSinks.One.tryEmitValue(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,
Sinks.One.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, ...).- Specified by:
emitValuein interfaceSinks.One<T>- 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.- See Also:
-
-
emitEmpty
Description copied from interface:Sinks.EmptyA simplified attempt at completing via theSinks.Empty.tryEmitEmpty()API, generating anonCompletesignal. If the result of the attempt is not asuccess, implementations SHOULD retry theSinks.Empty.tryEmitEmpty()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,
Sinks.Empty.tryEmitEmpty()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_OVERFLOW: irrelevant as onComplete is not driven by backpressure. -
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER: the completion can be ignored since nobody is listening. Note that most vanilla reactor sinks never trigger this result for onComplete, replaying the terminal signal to later subscribers instead (to the exception ofSinks.UnicastSpec.onBackpressureError()). -
Sinks.EmitResult.FAIL_CANCELLED: the completion can be ignored since nobody is interested. -
Sinks.EmitResult.FAIL_TERMINATED: the extra completion is basically ignored since there was a previous termination signal, but there is nothing interesting to log. -
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 in 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, ...).- Specified by:
emitEmptyin interfaceSinks.Empty<T>- Parameters:
failureHandler- the failure handler that allows retrying failedSinks.EmitResult.- See Also:
-
-
emitError
Description copied from interface:Sinks.EmptyA simplified attempt at failing the sequence via theSinks.Empty.tryEmitError(Throwable)API, generating anonErrorsignal. If the result of the attempt is not asuccess, implementations SHOULD retry theSinks.Empty.tryEmitError(Throwable)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,
Sinks.Empty.tryEmitError(Throwable)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_OVERFLOW: irrelevant as onError is not driven by backpressure. -
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER: the error is ignored since nobody is listening. Note that most vanilla reactor sinks never trigger this result for onError, replaying the terminal signal to later subscribers instead (to the exception ofSinks.UnicastSpec.onBackpressureError()). -
Sinks.EmitResult.FAIL_CANCELLED: the error can be ignored since nobody is interested. -
Sinks.EmitResult.FAIL_TERMINATED: the error unexpectedly follows another terminal signal, so it is dropped viaOperators.onErrorDropped(Throwable, 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 in 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, ...).- Specified by:
emitErrorin interfaceSinks.Empty<T>- Parameters:
error- the exception to signal, not nullfailureHandler- the failure handler that allows retrying failedSinks.EmitResult.- See Also:
-
-
currentContext
Context currentContext()Request aContextfrom dependent components which can include downstream operators during subscribing or a terminalSubscriber.- Returns:
- a resolved context
-
tryEmitEmpty
Description copied from interface:Sinks.EmptyTry to complete theMonowithout a value, generating only anonCompletesignal. The result of the attempt is represented as anSinks.EmitResult, which possibly indicates error cases.See the list of failure
Sinks.EmitResultinSinks.Empty.emitEmpty(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.- Specified by:
tryEmitEmptyin interfaceSinks.Empty<T>- Returns:
- an
Sinks.EmitResult, which should be checked to distinguish different possible failures - See Also:
-
tryEmitError
Description copied from interface:Sinks.EmptyTry to fail theMono, generating only anonErrorsignal. The result of the attempt is represented as anSinks.EmitResult, which possibly indicates error cases.See the list of failure
Sinks.EmitResultinSinks.Empty.emitError(Throwable, 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.- Specified by:
tryEmitErrorin interfaceSinks.Empty<T>- Parameters:
t- the exception to signal, not null- Returns:
- an
Sinks.EmitResult, which should be checked to distinguish different possible failures - See Also:
-
currentSubscriberCount
public int currentSubscriberCount()Description copied from interface:Sinks.EmptyGet how manySubscribersare currently subscribed to the sink.This is a best effort peek at the sink state, and a subsequent attempt at emitting to the sink might still return
Sinks.EmitResult.FAIL_ZERO_SUBSCRIBERwhere relevant. Request (and lack thereof) isn't taken into account, all registered subscribers are counted.- Specified by:
currentSubscriberCountin interfaceSinks.Empty<T>- Returns:
- the number of active subscribers at the time of invocation
-
asMono
Description copied from interface:Sinks.EmptyReturn aMonoview of this sink. Every call returns the same instance.- Specified by:
asMonoin interfaceSinks.Empty<T>- Returns:
- the
Monoview associated to thisSinks.One
-
inners
Description copied from interface:ScannableReturn aStreamof referenced inners (flatmap, multicast etc) -
scanUnsafe
Description copied from interface:ScannableThis method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of theScannable.Attrkey, implementors should take care to return values of the correct type, and return null if no specific value is available.For public consumption of attributes, prefer using
Scannable.scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.- Specified by:
scanUnsafein interfaceScannable- Parameters:
key- aScannable.Attrto resolve for the component.- Returns:
- the value associated to the key for that specific component, or null if none.
-
currentContext
-