Interface EmissionStrategy

    • Method Detail

      • timeoutDrop

        static discord4j.common.sinks.TimeoutEmissionStrategy timeoutDrop​(Duration duration)
        Create an EmissionStrategy that will retry overflowing and non-serialized emissions until a given duration and drop values upon timeout.
        Parameters:
        duration - the Duration 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 an EmissionStrategy that will retry overflowing and non-serialized emissions until a given duration and error values upon timeout.
        Parameters:
        duration - the Duration to wait until elements are dropped
        Returns:
        a strategy with an error on timeout behavior
      • park

        static EmissionStrategy park​(Duration duration)
        Create an EmissionStrategy 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 - the Duration 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 given element to the specified sink, respecting the semantics of Sinks.Many.tryEmitNext(Object) and the failure handling of Sinks.Many.emitNext(Object, Sinks.EmitFailureHandler). Returns whether the emission was successful. Implementations can throw unchecked exceptions like Sinks.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
        element - 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 given sink successfully, respecting the semantics of Sinks.Many.tryEmitComplete() and the failure handling of Sinks.Many.emitComplete(Sinks.EmitFailureHandler). Returns whether the emission was successful. Implementations can throw unchecked exceptions like Sinks.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 given sink, respecting the semantics of Sinks.Many.tryEmitError(Throwable) and the failure handling of Sinks.Many.emitError(Throwable, Sinks.EmitFailureHandler). Returns whether the emission was successful. Implementations can throw unchecked exceptions like Sinks.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
        error - the exception to signal, non-null
        Returns:
        the result of the emission, true if the failure was correctly emitted, false otherwise