Package discord4j.common.sinks
Interface EmissionStrategy
A strategy to handle emission failures to a
Sinks.Many instance.-
Method Summary
Modifier and TypeMethodDescription<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 EmissionStrategyCreate 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 Details
-
timeoutDrop
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
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
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
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
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
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
-