Package reactor.core.publisher
Interface Sinks.EmitFailureHandler
- Enclosing class:
- Sinks
public static interface Sinks.EmitFailureHandler
A handler supporting the emit API (eg.
Sinks.Many.emitNext(Object, Sinks.EmitFailureHandler)),
checking non-successful emission results from underlying tryEmit
API calls to decide whether or not such calls should be retried.
Other than instructing to retry, the handlers are allowed to have side effects
like parking the current thread for longer retry loops. They don't, however, influence the
exact action taken by the emit API implementations when the handler doesn't allow
the retry to occur.- Implementation Note:
- It is expected that the handler may perform side effects (e.g. busy looping)
and should not be considered a plain
Predicate.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Sinks.EmitFailureHandlerA pre-made handler that will not instruct to retry any failure and trigger the failure handling immediately. -
Method Summary
Modifier and TypeMethodDescriptionstatic Sinks.EmitFailureHandlerbusyLooping(Duration duration) Create anSinks.EmitFailureHandlerwhich will busy loop in case of concurrent use of the sink (Sinks.EmitResult.FAIL_NON_SERIALIZED, up to a deadline.booleanonEmitFailure(SignalType signalType, Sinks.EmitResult emitResult) Decide whether the emission should be retried, depending on the providedSinks.EmitResultand the type of operation that was attempted (represented as aSignalType).
-
Field Details
-
FAIL_FAST
A pre-made handler that will not instruct to retry any failure and trigger the failure handling immediately.
-
-
Method Details
-
busyLooping
Create anSinks.EmitFailureHandlerwhich will busy loop in case of concurrent use of the sink (Sinks.EmitResult.FAIL_NON_SERIALIZED, up to a deadline. The deadline is computed immediately from the current time (construction time) + providedDuration.As a result there will always be some delay between this computation and the actual first use of the handler (at a minimum, the time it takes for the first sink emission attempt). Consider this when choosing the
Duration, and probably prefer something above 100ms, and don't cache the returning handler for later usage.- Parameters:
duration-Durationfor the deadline- Returns:
- an optimistic and bounded busy-looping
Sinks.EmitFailureHandler
-
onEmitFailure
Decide whether the emission should be retried, depending on the providedSinks.EmitResultand the type of operation that was attempted (represented as aSignalType). Side effects are allowed.- Parameters:
signalType- the signal that triggered the emission. Can be eitherSignalType.ON_NEXT,SignalType.ON_ERRORorSignalType.ON_COMPLETE.emitResult- the result of the emission (a failure)- Returns:
trueif the operation should be retried,falseotherwise.
-