public class Reactor extends Object
Modifier and Type | Field and Description |
---|---|
static Duration |
DEFAULT_EMIT_BUSY_DURATION |
Modifier and Type | Method and Description |
---|---|
static Sinks.EmitFailureHandler |
emitFailureHandler()
Constructs a new EmitFailureHandler with the default busy wait duration.
|
static Sinks.EmitFailureHandler |
emitFailureHandler(Duration duration)
Constructs a new EmitFailureHandler with a custom busy wait duration.
|
static <T> Flux<T> |
shieldFromCancellation(Flux<T> flux)
Returns a new Flux that wraps the given Flux and receives events from it.
|
static <T,C extends Iterable<T>> |
toFlux(Supplier<CompletableFuture<C>> input)
Helper method to wrap an async call into a reactive one and translate
exceptions appropriately.
|
static <T> Mono<T> |
toMono(Supplier<CompletableFuture<T>> input)
Helper method to wrap an async call into a reactive one and translate
exceptions appropriately.
|
static <T> Mono<T> |
wrap(CompletableFuture<T> response,
Runnable cancellationTask)
Converts the given future into a mono.
|
static <T> Mono<T> |
wrap(Request<?> request,
CompletableFuture<T> response,
boolean propagateCancellation)
|
public static final Duration DEFAULT_EMIT_BUSY_DURATION
public static <T> Mono<T> wrap(Request<?> request, CompletableFuture<T> response, boolean propagateCancellation)
request
- the request to wrap.response
- the full response to wrap, might not be the same as in the request.propagateCancellation
- if a cancelled/unsubscribed mono should also cancel the
request.@Stability.Internal public static <T> Mono<T> wrap(CompletableFuture<T> response, Runnable cancellationTask)
public static <T> Mono<T> toMono(Supplier<CompletableFuture<T>> input)
input
- a supplier that will be called on every subscription.public static <T,C extends Iterable<T>> Flux<T> toFlux(Supplier<CompletableFuture<C>> input)
input
- a supplier that will be called on every subscription.public static Sinks.EmitFailureHandler emitFailureHandler()
DEFAULT_EMIT_BUSY_DURATION
.public static Sinks.EmitFailureHandler emitFailureHandler(Duration duration)
duration
- the duration to busy loop until failure.public static <T> Flux<T> shieldFromCancellation(Flux<T> flux)
Useful for cooperative cancellation schemes, where an external flag
(typically an AtomicBoolean
) is set whenever the
inner Flux should stop emitting events. The external flag is typically
set by a Flux.doOnCancel(java.lang.Runnable)
callback on the returned Flux.
This allows the inner Flux to do non-trivial cleanup work before it terminates.
Copyright © 2024 Couchbase, Inc.. All rights reserved.