@Stability.Internal public final class CoreAsyncResponse<T> extends Object
CompletableFuture
with a cancellation task.
Lets the Async API tell the Reactive API how to cancel a request in a protocol-agnostic way, so the default implementation of the Reactive API works with both Classic and Protostellar.
A CompletableFuture alone is not sufficient, because a completion stage does not propagate cancellation upstream. If the Async API methods were to return only a CompletableFuture, they could not reliably attach the cancellation logic required by the Reactive API methods (which by default are thin wrappers over the Async APIs).
Constructor and Description |
---|
CoreAsyncResponse(CompletableFuture<T> future,
Runnable cancellationTask) |
Modifier and Type | Method and Description |
---|---|
<U> CoreAsyncResponse<U> |
flatMap(Function<? super T,? extends CoreAsyncResponse<U>> fn) |
<U> CoreAsyncResponse<U> |
map(Function<? super T,? extends U> fn) |
<U> CompletableFuture<U> |
thenApply(Function<? super T,? extends U> fn) |
<U> CompletableFuture<U> |
thenCompose(Function<? super T,? extends CompletableFuture<U>> fn) |
T |
toBlocking() |
CompletableFuture<T> |
toFuture() |
CompletableFuture<Void> |
toFutureVoid() |
Mono<T> |
toMono() |
public CoreAsyncResponse(CompletableFuture<T> future, Runnable cancellationTask)
public T toBlocking()
public CompletableFuture<T> toFuture()
public CompletableFuture<Void> toFutureVoid()
public <U> CompletableFuture<U> thenApply(Function<? super T,? extends U> fn)
public <U> CompletableFuture<U> thenCompose(Function<? super T,? extends CompletableFuture<U>> fn)
public <U> CoreAsyncResponse<U> map(Function<? super T,? extends U> fn)
public <U> CoreAsyncResponse<U> flatMap(Function<? super T,? extends CoreAsyncResponse<U>> fn)
Copyright © 2024 Couchbase, Inc.. All rights reserved.