Enum Sinks.EmitResult

java.lang.Object
java.lang.Enum<Sinks.EmitResult>
reactor.core.publisher.Sinks.EmitResult
All Implemented Interfaces:
Serializable, Comparable<Sinks.EmitResult>, Constable
Enclosing class:
Sinks

public static enum Sinks.EmitResult extends Enum<Sinks.EmitResult>
Represents the immediate result of an emit attempt (eg. in Sinks.Many.tryEmitNext(Object). This does not guarantee that a signal is consumed, it simply refers to the sink state when an emit method is invoked. This is a particularly important distinction with regard to FAIL_CANCELLED which means the sink is -now- interrupted and emission can't proceed. Consequently, it is possible to emit a signal and obtain an "OK" status even if an in-flight cancellation is happening. This is due to the async nature of these actions: producer emits while consumer can interrupt independently.
  • Enum Constant Details

    • OK

      public static final Sinks.EmitResult OK
      Has successfully emitted the signal
    • FAIL_TERMINATED

      public static final Sinks.EmitResult FAIL_TERMINATED
      Has failed to emit the signal because the sink was previously terminated successfully or with an error
    • FAIL_OVERFLOW

      public static final Sinks.EmitResult FAIL_OVERFLOW
      Has failed to emit the signal because the sink does not have buffering capacity left
    • FAIL_CANCELLED

      public static final Sinks.EmitResult FAIL_CANCELLED
      Has failed to emit the signal because the sink was previously interrupted by its consumer
    • FAIL_NON_SERIALIZED

      public static final Sinks.EmitResult FAIL_NON_SERIALIZED
      Has failed to emit the signal because the access was not serialized
    • FAIL_ZERO_SUBSCRIBER

      public static final Sinks.EmitResult FAIL_ZERO_SUBSCRIBER
      Has failed to emit the signal because the sink has never been subscribed to has no capacity to buffer the signal.
  • Method Details

    • values

      public static Sinks.EmitResult[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static Sinks.EmitResult valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • isSuccess

      public boolean isSuccess()
      Represents a successful emission of a signal.

      This is more future-proof than checking for equality with OK since new OK-like codes could be introduced later.

    • isFailure

      public boolean isFailure()
      Represents a failure to emit a signal.
    • orThrow

      public void orThrow()
      Easily convert from an Sinks.EmitResult to throwing an exception on failure cases. This is useful if throwing is the most relevant way of dealing with a failed emission attempt. Note however that generally Reactor code doesn't favor throwing exceptions but rather propagating them through onError signals. See also orThrowWithCause(Throwable) in case of an emitError failure for which you want to attach the originally pushed Exception.
      See Also:
    • orThrowWithCause

      public void orThrowWithCause(Throwable cause)
      Easily convert from an Sinks.EmitResult to throwing an exception on failure cases. This is useful if throwing is the most relevant way of dealing with failed tryEmitError attempt, in which case you probably wants to propagate the originally pushed Exception. Note however that generally Reactor code doesn't favor throwing exceptions but rather propagating them through onError signals.
      See Also: