Package com.couchbase.client.core
Class Reactor
- java.lang.Object
-
- com.couchbase.client.core.Reactor
-
public class Reactor extends Object
This class provides utility methods when working with reactor.- Since:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static Duration
DEFAULT_EMIT_BUSY_DURATION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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,C extends Iterable<T>>
Flux<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(Request<?> request, CompletableFuture<T> response, boolean propagateCancellation)
-
-
-
Field Detail
-
DEFAULT_EMIT_BUSY_DURATION
public static final Duration DEFAULT_EMIT_BUSY_DURATION
-
-
Method Detail
-
wrap
public static <T> Mono<T> wrap(Request<?> request, CompletableFuture<T> response, boolean propagateCancellation)
- Parameters:
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.- Returns:
- the mono that wraps the request.
-
toMono
public static <T> Mono<T> toMono(Supplier<CompletableFuture<T>> input)
Helper method to wrap an async call into a reactive one and translate exceptions appropriately.- Parameters:
input
- a supplier that will be called on every subscription.- Returns:
- a mono that invokes the given supplier on each subscription.
-
toFlux
public static <T,C extends Iterable<T>> Flux<T> toFlux(Supplier<CompletableFuture<C>> input)
Helper method to wrap an async call into a reactive one and translate exceptions appropriately.- Parameters:
input
- a supplier that will be called on every subscription.- Returns:
- a flux that invokes the given supplier on each subscription.
-
emitFailureHandler
public static Sinks.EmitFailureHandler emitFailureHandler()
Constructs a new EmitFailureHandler with the default busy wait duration.- Returns:
- a new emit failure handler, busy looping for
DEFAULT_EMIT_BUSY_DURATION
.
-
emitFailureHandler
public static Sinks.EmitFailureHandler emitFailureHandler(Duration duration)
Constructs a new EmitFailureHandler with a custom busy wait duration.- Parameters:
duration
- the duration to busy loop until failure.- Returns:
- a new emit failure handler, busy looping for the given duration.
-
-