T
- the value type emittedpublic interface MonoSink<T>
限定符和类型 | 方法和说明 |
---|---|
default ContextView |
contextView()
Return the current subscriber's context as a
ContextView for inspection. |
Context |
currentContext()
已过时。
To be removed in 3.6.0 at the earliest. Prefer using #getContextView() instead.
|
void |
error(java.lang.Throwable e)
抛出一个异常。
|
MonoSink<T> |
onCancel(Disposable d)
取消订阅事件,调用
Subscription.cancel() 方法触发,多次注册以最后一次为准,当元素发布后再调用取消订阅时不生效
Attach a Disposable as a callback for when this MonoSink is
cancelled. |
MonoSink<T> |
onDispose(Disposable d)
在完成时,在发生异常时(onComplete, onError),在Subscription调用
Subscription.cancel() 方法取消时触发,可重复注册
Attach a Disposable as a callback for when this MonoSink is effectively
disposed, that is it cannot be used anymore. |
MonoSink<T> |
onRequest(java.util.function.LongConsumer consumer)
请求事件,订阅者订阅后发起请求数据时触发,会传入一个Long型的背压数,默认是Long.MAX_VALUE
Attaches a
LongConsumer to this MonoSink that will be notified of
any request to this sink. |
void |
success()
发布一个空消息。
|
void |
success(T value)
发布一个消息,消息发布后 MonoSink 会忽略后续消息和异常的发布
Complete this
Mono with the given value. |
void success()
Complete without any value.
Calling this method multiple times or after the other terminating methods has no effect.
void success(@Nullable T value)
Complete this Mono
with the given value.
Calling this method multiple times or after the other
terminating methods has no effect (the value is dropped
).
Calling this method with a null
value will be silently accepted as a call to
success()
by standard implementations.
value
- the value to complete withvoid error(java.lang.Throwable e)
Terminate with the given exception
Calling this method multiple times or after the other terminating methods is
an unsupported operation. It will discard the exception through the
Hooks.onErrorDropped(Consumer)
hook. This is to avoid
complete and silent swallowing of the exception.
e
- the exception to complete with@Deprecated Context currentContext()
Context
.
Context
can be enriched via Mono.contextWrite(Function)
operator or directly by a child subscriber overriding
CoreSubscriber.currentContext()
default ContextView contextView()
ContextView
for inspection.
Context
can be enriched downstream via Mono.contextWrite(Function)
operator or directly by a child subscriber overriding CoreSubscriber.currentContext()
.
ContextView
.MonoSink<T> onRequest(java.util.function.LongConsumer consumer)
Attaches a LongConsumer
to this MonoSink
that will be notified of
any request to this sink.
consumer
- the consumer to invoke on requestMonoSink
with a consumer that is notified of requestsMonoSink<T> onCancel(Disposable d)
Subscription.cancel()
方法触发,多次注册以最后一次为准,当元素发布后再调用取消订阅时不生效
Attach a Disposable
as a callback for when this MonoSink
is
cancelled. At most one callback can be registered, and subsequent calls to this method
will result in the immediate disposal of the extraneous Disposable
.
The callback is only relevant when the downstream Subscription
is cancelled
.
d
- the Disposable
to use as a callbackMonoSink
with a cancellation callbackonDispose(Disposable) for a callback that covers cancellation AND terminal signals
MonoSink<T> onDispose(Disposable d)
Subscription.cancel()
方法取消时触发,可重复注册
Attach a Disposable
as a callback for when this MonoSink
is effectively
disposed, that is it cannot be used anymore. This includes both having played terminal
signals (onComplete, onError) and having been cancelled (see onCancel(Disposable)
).
At most one callback can be registered, and subsequent calls to this method will result in
the immediate disposal of the extraneous Disposable
.
Note that the "dispose" term is used from the perspective of the sink. Not to
be confused with Mono.subscribe()
's Disposable.dispose()
method, which
maps to disposing the Subscription
(effectively, a Subscription.cancel()
signal).
d
- the Disposable
to use as a callbackMonoSink
with a callback invoked on any terminal signal or on cancellationonCancel(Disposable) for a cancellation-only callback