Package discord4j.common.sinks
Interface EmissionStrategy
-
@Experimental public interface EmissionStrategy
A strategy to handle emission failures to aSinks.Manyinstance.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> booleanemitComplete(Sinks.Many<T> sink)Try to terminate the givensinksuccessfully, respecting the semantics ofSinks.Many.tryEmitComplete()and the failure handling ofSinks.Many.emitComplete(Sinks.EmitFailureHandler).<T> booleanemitError(Sinks.Many<T> sink, Throwable error)Try to fail the givensink, respecting the semantics ofSinks.Many.tryEmitError(Throwable)and the failure handling ofSinks.Many.emitError(Throwable, Sinks.EmitFailureHandler).<T> booleanemitNext(Sinks.Many<T> sink, T element)Try emitting a givenelementto the specifiedsink, respecting the semantics ofSinks.Many.tryEmitNext(Object)and the failure handling ofSinks.Many.emitNext(Object, Sinks.EmitFailureHandler).static EmissionStrategypark(Duration duration)Create anEmissionStrategythat will indefinitely park emissions on overflow or non-serialized scenarios until it resolves, the emitter is cancelled or the sink is terminated.static discord4j.common.sinks.TimeoutEmissionStrategytimeoutDrop(Duration duration)Create anEmissionStrategythat will retry overflowing and non-serialized emissions until a givendurationand drop values upon timeout.static discord4j.common.sinks.TimeoutEmissionStrategytimeoutError(Duration duration)Create anEmissionStrategythat will retry overflowing and non-serialized emissions until a givendurationand error values upon timeout.
-
-
-
Method Detail
-
timeoutDrop
static discord4j.common.sinks.TimeoutEmissionStrategy timeoutDrop(Duration duration)
Create anEmissionStrategythat will retry overflowing and non-serialized emissions until a givendurationand drop values upon timeout.- Parameters:
duration- theDurationto wait until elements are dropped- Returns:
- a strategy with a drop on timeout behavior
-
timeoutError
static discord4j.common.sinks.TimeoutEmissionStrategy timeoutError(Duration duration)
Create anEmissionStrategythat will retry overflowing and non-serialized emissions until a givendurationand error values upon timeout.- Parameters:
duration- theDurationto wait until elements are dropped- Returns:
- a strategy with an error on timeout behavior
-
park
static EmissionStrategy park(Duration duration)
Create anEmissionStrategythat will indefinitely park emissions on overflow or non-serialized scenarios until it resolves, the emitter is cancelled or the sink is terminated.- Parameters:
duration- theDurationindicating how long to disable the emitting thread after each failed attempt- Returns:
- a strategy that awaits emissions on overflowing sinks
-
emitNext
<T> boolean emitNext(Sinks.Many<T> sink, T element)
Try emitting a givenelementto the specifiedsink, respecting the semantics ofSinks.Many.tryEmitNext(Object)and the failure handling ofSinks.Many.emitNext(Object, Sinks.EmitFailureHandler). Returns whether the emission was successful. Implementations can throw unchecked exceptions likeSinks.EmissionExceptionor perform side-effects like waiting to determine a result.- Type Parameters:
T- the type associated with the sink and element- Parameters:
sink- the target sink where this emission is attemptedelement- the element pushed to the sink- Returns:
- the result of the emission,
trueif the element was pushed to the sink,falseotherwise
-
emitComplete
<T> boolean emitComplete(Sinks.Many<T> sink)
Try to terminate the givensinksuccessfully, respecting the semantics ofSinks.Many.tryEmitComplete()and the failure handling ofSinks.Many.emitComplete(Sinks.EmitFailureHandler). Returns whether the emission was successful. Implementations can throw unchecked exceptions likeSinks.EmissionExceptionor perform side-effects like waiting to determine a result.- Type Parameters:
T- the type associated with the sink and element- Parameters:
sink- the target sink where this emission is attempted- Returns:
- the result of the emission,
trueif the sink was terminated successfully,falseotherwise
-
emitError
<T> boolean emitError(Sinks.Many<T> sink, Throwable error)
Try to fail the givensink, respecting the semantics ofSinks.Many.tryEmitError(Throwable)and the failure handling ofSinks.Many.emitError(Throwable, Sinks.EmitFailureHandler). Returns whether the emission was successful. Implementations can throw unchecked exceptions likeSinks.EmissionExceptionor perform side-effects like waiting to determine a result.- Type Parameters:
T- the type associated with the sink and element- Parameters:
sink- the target sink where this emission is attemptederror- the exception to signal, non-null- Returns:
- the result of the emission,
trueif the failure was correctly emitted,falseotherwise
-
-