public static interface Sinks.EmitFailureHandler
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.Predicate
.Modifier and Type | Field and Description |
---|---|
static Sinks.EmitFailureHandler |
FAIL_FAST
A pre-made handler that will not instruct to retry any failure
and trigger the failure handling immediately.
|
Modifier and Type | Method and Description |
---|---|
static Sinks.EmitFailureHandler |
busyLooping(Duration duration)
Create an
Sinks.EmitFailureHandler which will busy loop in case of concurrent use
of the sink (Sinks.EmitResult.FAIL_NON_SERIALIZED , up to a deadline. |
boolean |
onEmitFailure(SignalType signalType,
Sinks.EmitResult emitResult)
Decide whether the emission should be retried, depending on the provided
Sinks.EmitResult
and the type of operation that was attempted (represented as a SignalType ). |
static final Sinks.EmitFailureHandler FAIL_FAST
static Sinks.EmitFailureHandler busyLooping(Duration duration)
Sinks.EmitFailureHandler
which 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)
+ provided Duration
.
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.
duration
- Duration
for the deadlineSinks.EmitFailureHandler
boolean onEmitFailure(SignalType signalType, Sinks.EmitResult emitResult)
Sinks.EmitResult
and the type of operation that was attempted (represented as a SignalType
).
Side effects are allowed.signalType
- the signal that triggered the emission. Can be either SignalType.ON_NEXT
, SignalType.ON_ERROR
or SignalType.ON_COMPLETE
.emitResult
- the result of the emission (a failure)true
if the operation should be retried, false
otherwise.