O
- the type of the value that will be made availablepublic final class MonoProcessor<O> extends Mono<O> implements Processor<O,O>, CoreSubscriber<O>, Disposable, Subscription, Scannable, LongSupplier
MonoProcessor
is a Mono
extension that implements stateful semantics. Multi-subscribe is allowed.
Once a MonoProcessor
has been resolved, newer subscribers will benefit from the cached result.
Disposable.Composite, Disposable.Swap
Scannable.Attr<T>
OPERATOR_NAME_UNRELATED_WORDS_PATTERN
Modifier and Type | Method and Description |
---|---|
O |
block()
Block the calling thread indefinitely, waiting for the completion of this
MonoProcessor . |
O |
block(Duration timeout)
Block the calling thread for the specified time, waiting for the completion of this
MonoProcessor . |
void |
cancel() |
static <T> MonoProcessor<T> |
create()
Create a
MonoProcessor that will eagerly request 1 on onSubscribe(Subscription) , cache and emit
the eventual result for 1 or N subscribers. |
static <T> MonoProcessor<T> |
create(WaitStrategy waitStrategy)
Create a
MonoProcessor that will eagerly request 1 on onSubscribe(Subscription) , cache and emit
the eventual result for 1 or N subscribers. |
Context |
currentContext()
Request a
Context from dependent components which can include downstream
operators during subscribing or a terminal Subscriber . |
void |
dispose()
Cancel or dispose the underlying task or resource.
|
long |
downstreamCount()
Return the number of active
Subscriber or -1 if untracked. |
Throwable |
getError()
Return the produced
Throwable error if any or null |
boolean |
hasDownstreams()
Return true if any
Subscriber is actively subscribed |
Stream<? extends Scannable> |
inners()
Return a
Stream of referenced inners (flatmap, multicast etc) |
boolean |
isCancelled()
Indicates whether this
MonoProcessor has been interrupted via cancellation. |
boolean |
isDisposed()
Optionally return true when the resource or task is disposed.
|
boolean |
isError()
Indicates whether this
MonoProcessor has been completed with an error. |
boolean |
isSuccess()
Indicates whether this
MonoProcessor has been successfully completed a value. |
boolean |
isTerminated()
Indicates whether this
MonoProcessor has been terminated by the
source producer with a success or an error. |
void |
onComplete() |
void |
onError(Throwable cause) |
void |
onNext(O value) |
void |
onSubscribe(Subscription subscription)
Implementors should initialize any state used by
Subscriber.onNext(Object) before
calling Subscription.request(long) . |
O |
peek()
Returns the value that completed this
MonoProcessor . |
void |
request(long n) |
Object |
scanUnsafe(Scannable.Attr key)
This method is used internally by components to define their key-value mappings
in a single place.
|
void |
subscribe(CoreSubscriber<? super O> actual)
An internal
Publisher.subscribe(Subscriber) that will bypass
Hooks.onLastOperator(Function) pointcut. |
and, as, blockOptional, blockOptional, cache, cache, cache, cache, cancelOn, cast, checkpoint, checkpoint, checkpoint, compose, concatWith, create, defaultIfEmpty, defer, delay, delay, delayElement, delayElement, delaySubscription, delaySubscription, delaySubscription, delayUntil, dematerialize, doAfterSuccessOrError, doAfterTerminate, doFinally, doFirst, doOnCancel, doOnDiscard, doOnEach, doOnError, doOnError, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnSuccess, doOnSuccessOrError, doOnTerminate, elapsed, elapsed, empty, error, error, expand, expand, expandDeep, expandDeep, filter, filterWhen, first, first, flatMap, flatMapIterable, flatMapMany, flatMapMany, flux, from, fromCallable, fromCompletionStage, fromCompletionStage, fromDirect, fromFuture, fromFuture, fromRunnable, fromSupplier, handle, hasElement, hide, ignoreElement, ignoreElements, just, justOrEmpty, justOrEmpty, log, log, log, log, log, log, map, materialize, mergeWith, metrics, name, never, ofType, onAssembly, onErrorContinue, onErrorContinue, onErrorContinue, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, onErrorStop, onLastAssembly, onTerminateDetach, or, publish, publishOn, repeat, repeat, repeat, repeat, repeatWhen, repeatWhenEmpty, repeatWhenEmpty, retry, retry, retry, retry, retryBackoff, retryBackoff, retryBackoff, retryBackoff, retryBackoff, retryWhen, sequenceEqual, sequenceEqual, sequenceEqual, single, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscriberContext, subscriberContext, subscriberContext, subscribeWith, switchIfEmpty, tag, take, take, takeUntilOther, then, then, thenEmpty, thenMany, thenReturn, timeout, timeout, timeout, timeout, timeout, timeout, timestamp, timestamp, toFuture, toProcessor, toString, transform, using, using, usingWhen, usingWhen, when, when, whenDelayError, whenDelayError, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipWhen, zipWhen, zipWith, zipWith
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
actuals, from, isScanAvailable, name, parents, scan, scanOrDefault, stepName, steps, tags
getAsLong
@Nullable public O block()
MonoProcessor
. If the
MonoProcessor
is completed with an error a RuntimeException that wraps the error is thrown.@Nullable public O block(Duration timeout)
MonoProcessor
. If the
MonoProcessor
is completed with an error a RuntimeException that wraps the error is thrown.public final void cancel()
cancel
in interface Subscription
public static <T> MonoProcessor<T> create()
MonoProcessor
that will eagerly request 1 on onSubscribe(Subscription)
, cache and emit
the eventual result for 1 or N subscribers.T
- type of the expected valueMonoProcessor
.public static <T> MonoProcessor<T> create(WaitStrategy waitStrategy)
MonoProcessor
that will eagerly request 1 on onSubscribe(Subscription)
, cache and emit
the eventual result for 1 or N subscribers.T
- type of the expected valuewaitStrategy
- a WaitStrategy
for blocking block()
strategyMonoProcessor
.public Context currentContext()
CoreSubscriber
Context
from dependent components which can include downstream
operators during subscribing or a terminal Subscriber
.currentContext
in interface CoreSubscriber<O>
Context.empty()
public void dispose()
Disposable
Implementations are required to make this method idempotent.
dispose
in interface Disposable
public final long downstreamCount()
Subscriber
or -1 if untracked.Subscriber
or -1 if untracked@Nullable public final Throwable getError()
Throwable
error if any or nullThrowable
error if any or nullpublic final boolean hasDownstreams()
Subscriber
is actively subscribedSubscriber
is actively subscribedpublic Stream<? extends Scannable> inners()
Scannable
Stream
of referenced inners (flatmap, multicast etc)public boolean isCancelled()
MonoProcessor
has been interrupted via cancellation.true
if this MonoProcessor
is cancelled, false
otherwise.public boolean isDisposed()
Disposable
Implementations are not required to track disposition and as such may never return true even when disposed. However, they MUST only return true when there's a guarantee the resource or task is disposed.
isDisposed
in interface Disposable
public final boolean isError()
MonoProcessor
has been completed with an error.true
if this MonoProcessor
was completed with an error, false
otherwise.public final boolean isSuccess()
MonoProcessor
has been successfully completed a value.true
if this MonoProcessor
is successful, false
otherwise.public final boolean isTerminated()
MonoProcessor
has been terminated by the
source producer with a success or an error.true
if this MonoProcessor
is successful, false
otherwise.public final void onComplete()
onComplete
in interface Subscriber<O>
public final void onError(Throwable cause)
onError
in interface Subscriber<O>
public final void onNext(@Nullable O value)
onNext
in interface Subscriber<O>
public final void onSubscribe(Subscription subscription)
CoreSubscriber
Subscriber.onNext(Object)
before
calling Subscription.request(long)
. Should further onNext
related
state modification occur, thread-safety will be required.
Note that an invalid request <= 0
will not produce an onError and
will simply be ignored or reported through a debug-enabled
Logger
.
onSubscribe
in interface Subscriber<O>
onSubscribe
in interface CoreSubscriber<O>
@Nullable public O peek()
MonoProcessor
. Returns null
if the MonoProcessor
has not been completed. If the
MonoProcessor
is completed with an error a RuntimeException that wraps the error is thrown.MonoProcessor
, or null
if it has not been completedRuntimeException
- if the MonoProcessor
was completed with an errorpublic final void request(long n)
request
in interface Subscription
@Nullable public Object scanUnsafe(Scannable.Attr key)
Scannable
Scannable.Attr
key,
implementors should take care to return values of the correct type, and return
null if no specific value is available.
For public consumption of attributes, prefer using Scannable.scan(Attr)
, which will
return a typed value and fall back to the key's default if the component didn't
define any mapping.
scanUnsafe
in interface Scannable
key
- a Scannable.Attr
to resolve for the component.public void subscribe(CoreSubscriber<? super O> actual)
Mono
Publisher.subscribe(Subscriber)
that will bypass
Hooks.onLastOperator(Function)
pointcut.
In addition to behave as expected by Publisher.subscribe(Subscriber)
in a controlled manner, it supports direct subscribe-time Context
passing.
subscribe
in class Mono<O>
actual
- the Subscriber
interested into the published sequencePublisher.subscribe(Subscriber)