public static enum Sinks.EmitResult extends Enum<Sinks.EmitResult>
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 and Description |
---|
FAIL_CANCELLED
Has failed to emit the signal because the sink was previously interrupted by its consumer
|
FAIL_NON_SERIALIZED
Has failed to emit the signal because the access was not serialized
|
FAIL_OVERFLOW
Has failed to emit the signal because the sink does not have buffering capacity left
|
FAIL_TERMINATED
Has failed to emit the signal because the sink was previously terminated successfully or with an error
|
FAIL_ZERO_SUBSCRIBER
Has failed to emit the signal because the sink has never been subscribed to has no capacity
to buffer the signal.
|
OK
Has successfully emitted the signal
|
Modifier and Type | Method and Description |
---|---|
boolean |
isFailure()
Represents a failure to emit a signal.
|
boolean |
isSuccess()
Represents a successful emission of a signal.
|
void |
orThrow()
Easily convert from an
Sinks.EmitResult to throwing an exception on failure cases . |
void |
orThrowWithCause(Throwable cause)
Easily convert from an
Sinks.EmitResult to throwing an exception on failure cases . |
static Sinks.EmitResult |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Sinks.EmitResult[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Sinks.EmitResult OK
public static final Sinks.EmitResult FAIL_TERMINATED
public static final Sinks.EmitResult FAIL_OVERFLOW
public static final Sinks.EmitResult FAIL_CANCELLED
public static final Sinks.EmitResult FAIL_NON_SERIALIZED
public static final Sinks.EmitResult FAIL_ZERO_SUBSCRIBER
public static Sinks.EmitResult[] values()
for (Sinks.EmitResult c : Sinks.EmitResult.values()) System.out.println(c);
public static Sinks.EmitResult valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic boolean isSuccess()
This is more future-proof than checking for equality with OK
since
new OK-like codes could be introduced later.
public boolean isFailure()
public void orThrow()
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
.orThrowWithCause(Throwable)
public void orThrowWithCause(Throwable cause)
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.orThrow()