Package discord4j.common.sinks
Interface EmissionStrategy
-
@Experimental public interface EmissionStrategy
A strategy to handle emission failures to aSinks.Many
instance.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> boolean
emitComplete(Sinks.Many<T> sink)
Try to terminate the givensink
successfully, respecting the semantics ofSinks.Many.tryEmitComplete()
and the failure handling ofSinks.Many.emitComplete(Sinks.EmitFailureHandler)
.<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)
.<T> boolean
emitNext(Sinks.Many<T> sink, T element)
Try emitting a givenelement
to the specifiedsink
, respecting the semantics ofSinks.Many.tryEmitNext(Object)
and the failure handling ofSinks.Many.emitNext(Object, Sinks.EmitFailureHandler)
.static EmissionStrategy
park(Duration duration)
Create anEmissionStrategy
that 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.TimeoutEmissionStrategy
timeoutDrop(Duration duration)
Create anEmissionStrategy
that will retry overflowing and non-serialized emissions until a givenduration
and drop values upon timeout.static discord4j.common.sinks.TimeoutEmissionStrategy
timeoutError(Duration duration)
Create anEmissionStrategy
that will retry overflowing and non-serialized emissions until a givenduration
and error values upon timeout.
-
-
-
Method Detail
-
timeoutDrop
static discord4j.common.sinks.TimeoutEmissionStrategy timeoutDrop(Duration duration)
Create anEmissionStrategy
that will retry overflowing and non-serialized emissions until a givenduration
and drop values upon timeout.- Parameters:
duration
- theDuration
to wait until elements are dropped- Returns:
- a strategy with a drop on timeout behavior
-
timeoutError
static discord4j.common.sinks.TimeoutEmissionStrategy timeoutError(Duration duration)
Create anEmissionStrategy
that will retry overflowing and non-serialized emissions until a givenduration
and error values upon timeout.- Parameters:
duration
- theDuration
to wait until elements are dropped- Returns:
- a strategy with an error on timeout behavior
-
park
static EmissionStrategy park(Duration duration)
Create anEmissionStrategy
that will indefinitely park emissions on overflow or non-serialized scenarios until it resolves, the emitter is cancelled or the sink is terminated.- Parameters:
duration
- theDuration
indicating 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 givenelement
to 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.EmissionException
or 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,
true
if the element was pushed to the sink,false
otherwise
-
emitComplete
<T> boolean emitComplete(Sinks.Many<T> sink)
Try to terminate the givensink
successfully, 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.EmissionException
or 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,
true
if the sink was terminated successfully,false
otherwise
-
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.EmissionException
or 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,
true
if the failure was correctly emitted,false
otherwise
-
-