public static enum Sinks.EmitResult extends java.lang.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.枚举常量和说明 |
---|
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
|
限定符和类型 | 方法和说明 |
---|---|
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(java.lang.Throwable cause)
Easily convert from an
Sinks.EmitResult to throwing an exception on failure cases . |
static Sinks.EmitResult |
valueOf(java.lang.String name)
返回带有指定名称的该类型的枚举常量。
|
static Sinks.EmitResult[] |
values()
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。
|
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(java.lang.String name)
name
- 要返回的枚举常量的名称。java.lang.IllegalArgumentException
- 如果该枚举类型没有带有指定名称的常量java.lang.NullPointerException
- 如果参数为空值public 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
.public void orThrowWithCause(java.lang.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()